Closed Bug 629639 Opened 14 years ago Closed 14 years ago

elfhack: unsupported symbol in relocation when building with stack protection

Categories

(Firefox Build System :: General, defect)

All
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla2.0b12

People

(Reporter: jdm, Assigned: glandium)

References

Details

Attachments

(3 files, 1 obsolete file)

===
=== 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/t_mattjo/src/firefox/mozilla-central/ff-dbg/build/unix/elfhack/elfhack -b test.so
test.so: terminate called after throwing an instance of 'std::runtime_error'
  what():  Unsupported symbol in relocation
make[6]: *** [test.so] Aborted (core dumped)
make[6]: *** Deleting file `test.so'

gcc version 4.4.4 20100630 (Red Hat 4.4.4-10) (GCC)
GNU ld version 2.19.51.0.14-37.fc12 20090722, coreutils 7.6-11
Fedora 12 x86
Could you give the output of readelf -r build/unix/elfhack/inject/*.o ?
Looks related to my https://bugzilla.mozilla.org/show_bug.cgi?id=629638, posted my output of readelf there.
Assignee: nobody → mh+mozilla
Status: NEW → ASSIGNED
(In reply to comment #0)
> ===
> === 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/t_mattjo/src/firefox/mozilla-central/ff-dbg/build/unix/elfhack/elfhack -b
> test.so
> test.so: terminate called after throwing an instance of 'std::runtime_error'
>   what():  Unsupported symbol in relocation
> make[6]: *** [test.so] Aborted (core dumped)
> make[6]: *** Deleting file `test.so'
> 
> gcc version 4.4.4 20100630 (Red Hat 4.4.4-10) (GCC)
> GNU ld version 2.19.51.0.14-37.fc12 20090722, coreutils 7.6-11
> Fedora 12 x86

Could you check if "make check" fails the same way with http://hg.mozilla.org/users/mh_glandium.org/elfhack/ (which contains the same elfhack code) ? I can't reproduce with a live fedora 12 system with the same versions as those you wrote.
Looks like make check passes.
(In reply to comment #4)
> Looks like make check passes.

Could you check comment 1 ?
Attached file readelf output
(In reply to comment #6)
> Created attachment 507960 [details]
> readelf output

00000014  00001403 R_386_GOT32       00000000   mcount

wtf is mcount ? Can you attach the output of objdump -d -r build/unix/elfhack/inject/x86.o ?
The preprocessed source would be helpful, too.
Forget it, I found what it is. http://lwn.net/Articles/264029/
I could trigger this with behaviour with the -pg option of gcc.
Summary: elfhack: unsupported symbol in relocation → elfhack: unsupported symbol in relocation when building with -pg option
The patch I attached in bug 629638 would allow you to build with elfhack enabled.
This doesn't solve the root of the problem, though.
If the root of the problem is that I'm building with -pg, that would be my fault.  I forgot that I added that to my mozconfig to see if I could get gprof output from my build.
(In reply to comment #11)
> If the root of the problem is that I'm building with -pg, that would be my
> fault.  I forgot that I added that to my mozconfig to see if I could get gprof
> output from my build.

Well, it's your fault and it's not your fault. The injected code is in C because it's more portable than assembly, but it is not designed to be built with fancy stuff like lto, pg, etc.
So in any case, it should be built with very controlled flags.
Attached file readelf -r *.o
Mike I have tested patch from bug 629638 , and still see the same failure. If there is anything you would like tested let me know.
(In reply to comment #13)
> Created attachment 508740 [details]
> readelf -r *.o
> 
> Mike I have tested patch from bug 629638 , and still see the same failure. If
> there is anything you would like tested let me know.

000000000074  000c00000004 R_X86_64_PLT32    0000000000000000 __stack_chk_fail - 4
I guess this comes from one of the hardening build options, I guess stack protection. How are you passing these options ? Are they built-in defaults to the compiler ?
(In reply to comment #14)
> (In reply to comment #13)
> > Created attachment 508740 [details]
> > readelf -r *.o
> > 
> > Mike I have tested patch from bug 629638 , and still see the same failure. If
> > there is anything you would like tested let me know.
> 
> 000000000074  000c00000004 R_X86_64_PLT32    0000000000000000 __stack_chk_fail
> - 4
> I guess this comes from one of the hardening build options, I guess stack
> protection. How are you passing these options ? Are they built-in defaults to
> the compiler ?
Mike, they are built into our hardened specs so the are automatically passed via the compiler.
dummy.c
test.c
elf.cpp
elfhack.cpp
x86_64.c
x86_64-noinit.c
===
=== 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.
===
test.so: Reduced by 12128 bytes
PASS

As you can see from the patch is a trivial work around, just need to ensure we pass -fno-stack-protector :)
This applies on top of bug 629638.

(In reply to comment #16)
> Created attachment 508875 [details] [diff] [review]
> ensure -fno-stack-protector is used for injection code
>
> As you can see from the patch is a trivial work around, just need to ensure we
> pass -fno-stack-protector :)

That was the patch from bug 629638 ;) but i get the idea
Attachment #508875 - Attachment is obsolete: true
Attachment #509036 - Flags: review?(khuey)
Sorry for the bug mess, it ended up being highjacked, but the original problem will be addressed in bug 629638.
Summary: elfhack: unsupported symbol in relocation when building with -pg option → elfhack: unsupported symbol in relocation when building with stack protection
Attachment #509036 - Flags: approval2.0?
Attachment #509036 - Flags: approval2.0? → approval2.0+
Pushed:
http://hg.mozilla.org/mozilla-central/rev/8a376e2a5400
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla2.0b12
Hardware: x86 → All
Version: unspecified → Trunk
Depends on: 629638
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: