[Bug ada/81087] array index out of range in gnatlink, making test always false

nicolas.boulenguez at free dot fr gcc-bugzilla@gcc.gnu.org
Thu Jun 15 09:37:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81087

--- Comment #2 from nicolas.boulenguez at free dot fr ---
> s/-gnatn/-gnatp I presume.
Yes.

> So can you write a testcase which demonstrates the malfunction of gnatlink?

The changes related to the Arg string probably only increase readability.
Ada.Command_Line.Argument probably returns a first index set to 1, although the
ARM does not require it.

The Debian bug report above seems obsolete, but here is a similar problem.

# echo "procedure Nope is begin null; end Nope;" > nope.adb
# gnatmake nope.adb -largs -v -Wl,-rpath,rpath1 -Wl,-rpath,rpath2
(Please adapt the run path option on non-Linux architectures.) 
The linker command then contains "-Wl,-rpath,rpath1 -Wl,-rpath,rpath2".
The test in gnatlink.adb:1263 should instead succeed, and the linker command
should contain "-Wl,-rpath,path1:path2".
(GNU ld fixes this afterwards, probably other linkers do not)

I thought that preventing out-of-bounds memory access would be consensual.

While at it, a more controversial suggestion is the removal of the
"Linker_Options.Table (J) /= null and then" part in line 1260.
Linker_Options.Table elements cannot be null (this should probably be stated in
a comment after the variable declaration). No other dereferences is checked.


More information about the Gcc-bugs mailing list