elfhack fails with "PT_GNU_RELRO segment doesn't start on a section start"

RESOLVED FIXED in mozilla7

Status

()

Core
Build Config
--
blocker
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: Jesse Ruderman, Assigned: glandium)

Tracking

Trunk
mozilla7
x86_64
Linux
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

6 years ago
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
(Reporter)

Comment 1

6 years ago
<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
(Reporter)

Comment 2

6 years ago
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
I filed bug 664367 for that second part.
Depends on: 664367
(Reporter)

Comment 4

6 years ago
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)
Blocks: 661800
No longer blocks: 661800
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
Attachment #539962 - Flags: review?(khuey)
Attachment #539962 - Flags: review?(khuey) → review+
Duplicate of this bug: 665049
http://hg.mozilla.org/integration/mozilla-inbound/rev/c669354b4930
Assignee: nobody → mh+mozilla
Whiteboard: [inbound]
http://hg.mozilla.org/mozilla-central/rev/c669354b4930
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
Whiteboard: [inbound]
Target Milestone: --- → mozilla7

Comment 11

6 years ago
(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.