Closed Bug 628283 Opened 14 years ago Closed 14 years ago

debug builds of elfhack fail test when linking with -z relro

Categories

(Firefox Build System :: General, defect)

All
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: glandium, Assigned: glandium)

References

(Depends on 1 open bug)

Details

(Whiteboard: [workaround: ac_add_options --disable-elf-hack])

Attachments

(1 file, 1 obsolete file)

When linking with "-z relro" passed to ld, or when ld defaults to that, elfhack, in debug builds (--enable-debug) fails its test with: .../elfhack -b test.so elfhack: ../../../../mozilla-central/build/unix/elfhack/elf.cpp:284: Elf::Elf(std::ifstream&): Assertion `segment->getFileSize() == phdr.p_filesz' failed. make: *** [test.so] Aborted make: *** Deleting file `test.so' This is due to the GNU_RELRO segment being weirdly defined. It seems to be ending at a page boundary (but doesn't start at a page boundary) instead of ending at the end of the last section it contains, which case elfhack doesn't handle.
Blocks: 606145
Attached patch Make elfhack handle GNU_RELRO segments better (obsolete) (deleted) — Splinter Review
Attachment #506423 - Flags: review?(tglek)
Attachment #506423 - Flags: approval2.0?
Comment on attachment 506423 [details] [diff] [review] Make elfhack handle GNU_RELRO segments better It looks like that while it passes the assertions, the resulting binary doesn't work well.
Attachment #506423 - Flags: review?(tglek)
Attachment #506423 - Flags: approval2.0?
(In reply to comment #3) > Comment on attachment 506423 [details] [diff] [review] > Make elfhack handle GNU_RELRO segments better > > It looks like that while it passes the assertions, the resulting binary doesn't > work well. Indeed, does not work for me. http://pastebin.mozilla.org/978658
I found the crash problem: we can't pack relocations that end up in the GNU_RELRO segment. People can work around this with --disable-elf-hack.
Attachment #506423 - Attachment is obsolete: true
Whiteboard: [workaround: ac_add_options --disable-elf-hack]
Attachment #506460 - Flags: review?(tglek)
Note that considering the crash from comment 4, I'm wondering why we're only seeing debug builds problems. We should also have similar segmentation faults in non debug builds.
Comment on attachment 506460 [details] [diff] [review] Make elfhack handle GNU_RELRO segments better v2 rubberstamp
Attachment #506460 - Flags: review?(tglek) → review+
Comment on attachment 506460 [details] [diff] [review] Make elfhack handle GNU_RELRO segments better v2 To be double sure this doesn't break anything while solving the issue, I pushed to try: 1fd4db06d4ab and that worked out pretty well.
Attachment #506460 - Flags: approval2.0?
Attachment #506460 - Flags: approval2.0? → approval2.0+
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
It still crashes on amd64 Linux: gcc -o inject/x86_64-noinit.o -c -I../../../dist/system_wrappers -include /var/tmp/mozilla-central/config/gcc_hidden.h -DOSTYPE=\"Linux2.6\" -DOSARCH=Linux -DBITS=64 -DNOINIT -I/var/tmp/mozilla-central/build/unix/elfhack -I. -I../../../dist/include -I../../../dist/include/nsprpub -I/var/tmp/mozilla-central/moz-build-dir/dist/include/nspr -I/var/tmp/mozilla-central/moz-build-dir/dist/include/nss -fPIC -Wall -W -Wno-unused -Wpointer-arith -Wcast-align -W -pedantic -Wno-long-long -march=native -fno-strict-aliasing -pthread -pipe -DNDEBUG -DTRIMMED -O3 -include ../../../mozilla-config.h -DMOZILLA_CLIENT -MD -MF .deps/x86_64-noinit.pp inject/x86_64-noinit.c c++ -o elfhack -fno-rtti -fno-exceptions -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 -march=native -fno-strict-aliasing -fshort-wchar -pthread -pipe -fexceptions -DNDEBUG -DTRIMMED -O3 host_elf.o host_elfhack.o c++ -fno-rtti -fno-exceptions -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 -march=native -fno-strict-aliasing -fshort-wchar -pthread -pipe -fexceptions -DNDEBUG -DTRIMMED -O3 -fPIC -shared -Wl,-z,defs -Wl,-h,test.so -o test.so test.o rm -f test.so.bak /var/tmp/mozilla-central/moz-build-dir/build/unix/elfhack/elfhack -b test.so make[6]: *** [test.so] Segmentation fault elfhack[8770]: segfault at 14 ip 000000000040a362 sp 00007ffffe971790 error 4 in elfhack[400000+11000] I'm running: GNU gold (Linux/GNU Binutils 2.21.51.0.6.20110118) 1.10
(In reply to comment #11) > It still crashes on amd64 Linux: That's another bug. Could you file one and attach your elfhack program as well as test.so ? Thanks
(In reply to comment #12) > (In reply to comment #11) > > It still crashes on amd64 Linux: > > That's another bug. Could you file one and attach your elfhack program as well > as test.so ? Thanks (And Cc me, obviously)
Depends on: 676198
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: