Re: polyorb build ok with gnat-4.9
On Fri, Feb 21, 2014 at 03:25:26PM +0100, Xavier Grave wrote:
> Although I have this in my gnatmake command line: -Wl,-z,relro I
> still have this lintian warning and get back at [3] with
> hardening-no-relro
> [3] https://lists.debian.org/debian-ada/2012/05/msg00016.html
# /usr/bin/hardening-check -v ELF_OBJECT reports the faulty
functions. I have seen strcpy reported in an object compiled from pure
Ada code, so a deeper explanation is needed, but this is quite rare.
However, the most probable cause is an incorrect advice in [3] :-).
In library project files:
* Library_Options are used when linking the dynamic library object
after compilation. The value, if any, looks like
LDFLAGS+LDLIBS=-Wl,-z,relro -Wl,--as-needed -lfoo -lbar. It is
ignored during static builds. Its little brother
Leading_Library_Options may work around some corner cases.
* Linker.Default_Switches ("Ada") in Linker package are used later
when linking another object depending on the library. The value, if
any, generally looks like LDLIBS=-lfoo -lbar. It is ignored when
linking the library itself after compilation.
Replace the project file in [3] with:
library project Foo is
Ldlibs := External_As_List ("LDLIBS", " ");
type Library_Kind is ("dynamic", "static");
Kind : Library_Kind := External ("KIND");
for Library_Name use Project'Name;
case Kind is
when "dynamic" =>
for Library_Version use "lib" & Project'Library_Name & ".so."
& External ("SOVERSION");
-- Build-time options use to link the shared library.
for Library_Options use External_As_List ("LDFLAGS", " ")
& Ldlibs;
when "static" =>
null;
end case;
for Library_Kind use Kind;
for Library_Dir use "build-lib-" & Kind;
for Object_Dir use "build-obj-" & Kind;
package Linker is
-- This package only exists to pass more options to importing
-- projects like demo/demo.gpr.
for Linker_Options use Ldlibs;
end Linker;
package Compiler is
for Default_Switches ("Ada") use External_As_List ("ADAFLAGS", " ");
for Default_Switches ("C") use External_As_List ("CPPFLAGS", " ")
& External_As_List ("CFLAGS", " ");
end Compiler;
-- This is needed so that gnatmake embeds .o files generated from .c sources,
-- even if it does not know how to compile them on its own.
for Languages use ("Ada", "C");
for Source_Dirs use ("src");
end Foo;
Dh_ada_library with then generate the packaged project, copying any -l
option from the Linker_Options of the dynamic build project into the
Linker.Default_Switches of the packaged project.
Reply to: