Page MenuHomeFreeBSD

csu: Find the main pointer through the GOT
ClosedPublic

Authored by andrew on May 20 2024, 11:59 AM.
Tags
None
Referenced Files
Unknown Object (File)
Jan 28 2025, 7:11 AM
Unknown Object (File)
Jan 17 2025, 4:01 PM
Unknown Object (File)
Dec 3 2024, 6:05 AM
Unknown Object (File)
Nov 30 2024, 11:15 AM
Unknown Object (File)
Nov 29 2024, 10:44 AM
Unknown Object (File)
Nov 25 2024, 4:42 AM
Unknown Object (File)
Nov 24 2024, 12:55 AM
Unknown Object (File)
Nov 23 2024, 1:17 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 Skipped
Unit
Tests Skipped
Build Status
Buildable 57773
Build 54661: arc lint + arc unit

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.May 20 2024, 5:32 PM

It was for something in the Google testing bits.

This revision was automatically updated to reflect the committed changes.