Page MenuHomeFreeBSD

test-includes: Build a library instead of a binary
ClosedPublic

Authored by imp on Dec 15 2021, 4:56 AM.
Tags
None
Referenced Files
Unknown Object (File)
May 3 2024, 9:54 AM
Unknown Object (File)
Apr 9 2024, 4:28 AM
Unknown Object (File)
Jan 21 2024, 1:42 PM
Unknown Object (File)
Jan 12 2024, 12:37 PM
Unknown Object (File)
Dec 20 2023, 2:30 AM
Unknown Object (File)
Dec 13 2023, 12:07 AM
Unknown Object (File)
Oct 24 2023, 6:51 AM
Unknown Object (File)
Oct 20 2023, 5:54 AM
Subscribers

Details

Summary

We need to build the .o's, but don't need to link. Build a static
library instead of a binary to accmoplish this. This removes the need to
have all the libc and crt stuff built, which is required for a
binary. In addition, trying to build a non-standard binary runs into
trouble with undefined symbols on arm related to EABI, even when using a
simplified startup with -nostdlib -e start.

Diff Detail

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

Event Timeline

imp requested review of this revision.Dec 15 2021, 4:56 AM
imp created this revision.
imp added reviewers: jrtc27, brooks, markj.

MIPS, being the usual odd one out, used __start not _start, FWIW...

Maybe best to be explicit with -e?

Alternatively you could build either a shared library or just the .o (/ a static library) and avoid the mild hackery needed to not get linker errors for the executable

-e _start to future proof

Alternatively you could build either a shared library or just the .o (/ a static library) and avoid the mild hackery needed to not get linker errors for the executable

I thought of that too... Years ago, I might have opted for the library, but libraries are becoming increasingly complex and I worry that it would be more fragile that -e, which seems a tiny bit more robust...

tools/build/test-includes/test-includes.c
1

Is this comment really accurate now that the entry point is specified in the linker flags?

Rework the comment to be correct, per markj

This revision is now accepted and ready to land.Dec 15 2021, 5:32 PM
imp retitled this revision from test-includes: Use _start instead of main to test-includes: Build a library instead of a binary.Dec 15 2021, 10:01 PM
imp edited the summary of this revision. (Show Details)
This revision now requires review to proceed.Dec 15 2021, 10:02 PM

Turns out brooks was right in a comment he left on the other review.
arm failed with the previous method, move to build a library method and see if that works.

This revision is now accepted and ready to land.Dec 15 2021, 10:19 PM