Page MenuHomeFreeBSD

Move to linker script for building boot images
ClosedPublic

Authored by imp on Aug 3 2016, 5:57 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Mar 16, 11:33 PM
Unknown Object (File)
Feb 22 2024, 10:41 PM
Unknown Object (File)
Feb 15 2024, 1:54 AM
Unknown Object (File)
Feb 10 2024, 1:00 PM
Unknown Object (File)
Jan 27 2024, 2:18 PM
Unknown Object (File)
Jan 15 2024, 9:30 PM
Unknown Object (File)
Dec 27 2023, 10:08 AM
Unknown Object (File)
Dec 20 2023, 3:51 AM
Subscribers
None

Details

Summary

Move to using a linker script in preference to -N when building binary blobs we put places.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

imp retitled this revision from to Move to linker script for building boot images.
imp updated this object.
imp edited the test plan for this revision. (Show Details)
imp added a reviewer: emaste.
imp set the repository for this revision to rS FreeBSD src repository - subversion.
sys/boot/i386/boot.ldscript
2–4

It isn't clear these three lines are needed. will test w/o them.

6

Not sure we have to set the origin.

7

Not sure I need the =0x90909090 here either.
What does it even do?

sys/boot/i386/Makefile.inc
33–34

Perhaps these two could have a comment explaining their use (i.e., flat binaries vs ELF output)?

sys/boot/pc98/boot0/Makefile
17

Oh, so we previously wrote an intermediate ELF file for just this one case and then converted it to a flat binary, but all others were output by ld directly as binaries?

sys/boot/i386/Makefile.inc
33–34

Isn't that what line 31 does?

sys/boot/pc98/boot0/Makefile
17

Correct. Up through https://svnweb.freebsd.org/base?view=revision&revision=128649 i386 did the same. Obrien never got around to this stray, and nyan-san never merged it either.

Note we also use -N in some mips, sparc64, and powerpc boot components. I think it's reasonable to leave them for a subsequent change.

sys/boot/i386/boot.ldscript
7

That's the value ld will use for padding - NOP NOP NOP NOP here. To me it seems like 0xcccccccc might be better (four INT3s) since we don't expect to execute random padding bytes between blocks of .text. But this is canonical and consistent with the rest of the system so I would leave it as is.

sys/boot/i386/Makefile.inc
33–34

I mean the use of LDFLAGS_BIN vs LD_FLAGS_BIN -- possibly ELF objects vs flat binaries? The line 31 comment applies mostly to the linker script itself IMO?

sys/boot/i386/Makefile.inc
33–34

LD_FLAGS vs LDFLAGS is a build system thing. LDFLAGS is used for $CC invocations while LD_FLAGS is used for direct $LD invocations.

sys/boot/i386/Makefile.inc
33–34

Right, but these are also producing different output format etc.
It looks like we're using the compiler driver invocation to produce flat binaries, and direct ld invocation to produce ELF objects.

sys/boot/i386/Makefile.inc
33–34

Oh, but it seems the direct ld invocations also use ${OBJCOPY} to convirt to a flat binary like pc98/boot0 used to anyhow.

Note we also use -N in some mips, sparc64, and powerpc boot components. I think it's reasonable to leave them for a subsequent change.

Does this militate to moving the boot.ldscript up to sys/boot and have it be called ldscript.$MACHINE?

Does this militate to moving the boot.ldscript up to sys/boot and have it be called ldscript.$MACHINE?

Seems that might be reasonable, although IMO it could be done in a subsequent change.

Looks good.

One little nit, LDFLAGS_BIN seems accurate as it's LDFLAGS for the compiler driver to output a binary directly; LD_FLAGS_BIN is the LD_FLAGS for the linker and is still outputting ELF so the name seems to be a slight mismatch.

For reference an lld change to support --oformat binary is in https://reviews.llvm.org/D23769.

This revision was automatically updated to reflect the committed changes.