Page MenuHomeFreeBSD

csu: Find the main pointer through the GOT
ClosedPublic

Authored by andrew on Mon, May 20, 11:59 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Jun 1, 2:59 AM
Unknown Object (File)
Sat, May 25, 1:50 PM
Unknown Object (File)
Fri, May 24, 4:49 PM
Unknown Object (File)
Wed, May 22, 7:53 PM
Unknown Object (File)
Wed, May 22, 5:58 PM
Unknown Object (File)
Wed, May 22, 12:29 PM
Unknown Object (File)
Wed, May 22, 9:45 AM
Unknown Object (File)
Tue, May 21, 1:40 PM
Subscribers
None

Details

Summary

Use the Global Offset Table to find the location of main in crt1. With
lld the old code would point to main@plt, however ld.bfd fails to link
when main is in a shared library.

Fix this by using the GOT address to find main as it works with both
lld and bfd.

Sponsored by: Arm Ltd

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

It surprises me that GNU ld doesn't want to create canonical PLTs, but avoiding them is reasonable; they are to functions what copy relocations are to data.

Putting main in a shared library sounds particularly cursed, but I guess it's not uncommon for testing frameworks. Presumably this is for libgtest_main.

This revision is now accepted and ready to land.Mon, May 20, 5:32 PM

It was for something in the Google testing bits.

This revision was automatically updated to reflect the committed changes.