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)
Thu, Nov 7, 1:01 AM
Unknown Object (File)
Sun, Oct 13, 9:40 AM
Unknown Object (File)
Oct 2 2024, 10:54 AM
Unknown Object (File)
Sep 30 2024, 9:43 PM
Unknown Object (File)
Sep 28 2024, 5:32 PM
Unknown Object (File)
Sep 28 2024, 8:37 AM
Unknown Object (File)
Sep 25 2024, 3:57 PM
Unknown Object (File)
Sep 17 2024, 6:34 PM
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