With Ubuntu 11.04 (g++ 4.5.2 and GNU ld 22.214.171.12410327), I get this error when I try to compile Firefox:
c++ -fno-rtti -Wall -Wpointer-arith -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -Wcast-align -Wno-invalid-offsetof -Wno-variadic-macros -Werror=return-type -Wno-long-long -fno-strict-aliasing -std=gnu++0x -pthread -pipe -fexceptions -DDEBUG -D_DEBUG -DTRACING -g -fPIC -shared -Wl,-z,defs -Wl,-h,test.so -o test.so test.o
=== If you get failures below, please file a bug describing the error
=== and your environment (compiler and linker versions), and use
=== --disable-elf-hack until this is fixed.
/home/jruderman/mozilla-central/objdir-ff-debug/build/unix/elfhack/elfhack -b test.so
test.so: terminate called after throwing an instance of 'std::runtime_error'
what(): PT_GNU_RELRO segment doesn't start on a section start
make: *** [test.so] Aborted
<glandium> it's an obvious bug in ld, the PT_GNU_RELRO segment doesn't even start on a page start
<glandium> iow, it's not page aligned
1. export LDFLAGS="-Wl,-z,norelro"
2. modify build/unix/elfhack/Makefile.in
> test$(DLL_SUFFIX): test.$(OBJ_SUFFIX) elfhack $(CSRCS:.c=.$(OBJ_SUFFIX))
>- $(MKSHLIB) $<
>+ $(MKSHLIB) $(LDFLAGS) $<
> @echo ===
> @echo === If you get failures below, please file a bug describing the error
I filed bug 664367 for that second part.
For the record, there are actually two problems in ld: the first one is the one I mentioned on irc, and pasted in comment 1, and the second one is that the RELRO segment starts on the .tbss section, instead of .init_array.
However, there still is an inconsistency in how elfhack treats this, because depending on the size of the .tbss section, the behaviour is not the same despite the section layout being similar.
(Note that this only happen when building with -Wl,-z,relro, which is the default on some distributions, which is why -Wl,-z,norelro is a workaround ; using gold instead of ld might work, too)
Trunk links fine for me with gold on Ubuntu 11.04 x64.
Created attachment 539962 [details] [diff] [review]
Automatically disable elfhack when the linker creates PT_GNU_RELRO segments
*** Bug 665049 has been marked as a duplicate of this bug. ***
(In reply to comment #9)
just to be clear , I have to use --disable-elf-hack every time i compile firefox on my system?
this bug is marked fixed but why am i still getting that error(i did hg pull and compiled today 7/2/11) ?
(In reply to comment #11)
> (In reply to comment #9)
> > http://hg.mozilla.org/integration/mozilla-inbound/rev/c669354b4930
> just to be clear , I have to use --disable-elf-hack every time i compile
> firefox on my system?
> this bug is marked fixed but why am i still getting that error(i did hg
> pull and compiled today 7/2/11) ?
Does you tree really contain that changeset?
If it does, check the configure output for "whether linker creates PT_GNU_RELRO segments"