Bug#396609: gnat-4.1: Link fails (Message: gnatlink.adb:1731 range check failed)
Hi Matthieu,
I have not been able to reproduce this bug, but it appears to be in a
Windows-specific part of gnatlink which we can safely remove. Could
you please try to recompile gnatlink with the following patch and see
if it solves your problem?
--
Ludovic Brenta.
--- /tmp/ediff15040_Tp 2006-11-18 01:42:14.000000000 +0100
+++ /tmp/gnatlink.adb 2006-11-18 01:42:14.000000000 +0100
@@ -1680,88 +1680,6 @@
IDENT_Op : Boolean := False;
begin
- -- Remove duplicate stack size setting from the Linker_Options
- -- table. The stack setting option "-Xlinker --stack=R,C" can be
- -- found in one line when set by a pragma Linker_Options or in two
- -- lines ("-Xlinker" then "--stack=R,C") when set on the command
- -- line. We also check for the "-Wl,--stack=R" style option.
-
- -- We must remove the second stack setting option instance
- -- because the one on the command line will always be the first
- -- one. And any subsequent stack setting option will overwrite the
- -- previous one. This is done especially for GNAT/NT where we set
- -- the stack size for tasking programs by a pragma in the NT
- -- specific tasking package System.Task_Primitives.Oparations.
-
- -- Note: This is not a FOR loop that runs from Linker_Options.First
- -- to Linker_Options.Last, since operations within the loop can
- -- modify the length of the table.
-
- Clean_Link_Option_Set : declare
- J : Natural := Linker_Options.First;
-
- begin
- while J <= Linker_Options.Last loop
-
- if Linker_Options.Table (J).all = "-Xlinker"
- and then J < Linker_Options.Last
- and then Linker_Options.Table (J + 1)'Length > 8
- and then Linker_Options.Table (J + 1) (1 .. 8) = "--stack="
- then
- if Stack_Op then
- Linker_Options.Table (J .. Linker_Options.Last - 2) :=
- Linker_Options.Table (J + 2 .. Linker_Options.Last);
- Linker_Options.Decrement_Last;
- Linker_Options.Decrement_Last;
- Num_Args := Num_Args - 2;
-
- else
- Stack_Op := True;
- end if;
- end if;
-
- -- Here we just check for a canonical form that matches the
- -- pragma Linker_Options set in the NT runtime.
-
- if (Linker_Options.Table (J)'Length > 17
- and then Linker_Options.Table (J) (1 .. 17)
- = "-Xlinker --stack=")
- or else
- (Linker_Options.Table (J)'Length > 12
- and then Linker_Options.Table (J) (1 .. 12)
- = "-Wl,--stack=")
- then
- if Stack_Op then
- Linker_Options.Table (J .. Linker_Options.Last - 1) :=
- Linker_Options.Table (J + 1 .. Linker_Options.Last);
- Linker_Options.Decrement_Last;
- Num_Args := Num_Args - 1;
-
- else
- Stack_Op := True;
- end if;
- end if;
-
- -- Remove duplicate IDENTIFICATION directives (VMS)
-
- if Linker_Options.Table (J)'Length > 27
- and then Linker_Options.Table (J) (1 .. 28)
- = "--for-linker=IDENTIFICATION="
- then
- if IDENT_Op then
- Linker_Options.Table (J .. Linker_Options.Last - 1) :=
- Linker_Options.Table (J + 1 .. Linker_Options.Last);
- Linker_Options.Decrement_Last;
- Num_Args := Num_Args - 1;
- else
- IDENT_Op := True;
- end if;
- end if;
-
- J := J + 1;
- end loop;
- end Clean_Link_Option_Set;
-
-- Prepare arguments for call to linker
Call_Linker : declare
Reply to: