Last Comment Bug 664366 - elfhack fails with "PT_GNU_RELRO segment doesn't start on a section start"
: elfhack fails with "PT_GNU_RELRO segment doesn't start on a section start"
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: Build Config (show other bugs)
: Trunk
: x86_64 Linux
: -- blocker (vote)
: mozilla7
Assigned To: Mike Hommey [:glandium]
:
Mentors:
: 665049 (view as bug list)
Depends on: 664367
Blocks:
  Show dependency treegraph
 
Reported: 2011-06-14 23:45 PDT by Jesse Ruderman
Modified: 2011-07-02 11:28 PDT (History)
11 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Automatically disable elfhack when the linker creates PT_GNU_RELRO segments (2.24 KB, patch)
2011-06-16 18:42 PDT, Mike Hommey [:glandium]
khuey: review+
Details | Diff | Splinter Review

Description Jesse Ruderman 2011-06-14 23:45:06 PDT
With Ubuntu 11.04 (g++ 4.5.2 and GNU ld 2.21.0.20110327), 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[7]: *** [test.so] Aborted
Comment 1 Jesse Ruderman 2011-06-14 23:46:19 PDT
<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
Comment 2 Jesse Ruderman 2011-06-14 23:47:50 PDT
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
Comment 3 Mike Hommey [:glandium] 2011-06-14 23:54:12 PDT
I filed bug 664367 for that second part.
Comment 4 Jesse Ruderman 2011-06-14 23:57:33 PDT
Easier workaround:

ac_add_options --disable-elf-hack
Comment 5 Mike Hommey [:glandium] 2011-06-16 07:23:53 PDT
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)
Comment 6 Justin Lebar (not reading bugmail) 2011-06-16 10:59:17 PDT
Trunk links fine for me with gold on Ubuntu 11.04 x64.
Comment 7 Mike Hommey [:glandium] 2011-06-16 18:42:35 PDT
Created attachment 539962 [details] [diff] [review]
Automatically disable elfhack when the linker creates PT_GNU_RELRO segments
Comment 8 :Ehsan Akhgari 2011-06-19 14:28:47 PDT
*** Bug 665049 has been marked as a duplicate of this bug. ***
Comment 11 michael getachew 2011-07-02 11:01:33 PDT
(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) ?
Comment 12 Mike Hommey [:glandium] 2011-07-02 11:28:26 PDT
(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"

Note You need to log in before you can comment on or make changes to this bug.