Closed Bug 664366 Opened 9 years ago Closed 9 years ago
elfhack fails with "PT
_GNU _RELRO segment doesn't start on a section start"
With Ubuntu 11.04 (g++ 4.5.2 and GNU ld 126.96.36.19910327), 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
Two-part workaround: 1. export LDFLAGS="-Wl,-z,norelro" 2. modify build/unix/elfhack/Makefile.in >ifndef CROSS_COMPILE > 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
Easier workaround: ac_add_options --disable-elf-hack
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.
Attachment #539962 - Flags: review?(khuey)
Attachment #539962 - Flags: review?(khuey) → review+
Assignee: nobody → mh+mozilla
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla7
(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) ?
(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"
You need to log in before you can comment on or make changes to this bug.