Move to using a linker script in preference to -N when building binary blobs we put places.
Details
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
sys/boot/i386/Makefile.inc | ||
---|---|---|
33–34 ↗ | (On Diff #19011) | Perhaps these two could have a comment explaining their use (i.e., flat binaries vs ELF output)? |
sys/boot/pc98/boot0/Makefile | ||
17 ↗ | (On Diff #19011) | 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 ↗ | (On Diff #19011) | Isn't that what line 31 does? |
sys/boot/pc98/boot0/Makefile | ||
17 ↗ | (On Diff #19011) | 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 ↗ | (On Diff #19011) | 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 ↗ | (On Diff #19011) | 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 ↗ | (On Diff #19011) | 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 ↗ | (On Diff #19011) | Right, but these are also producing different output format etc. |
sys/boot/i386/Makefile.inc | ||
---|---|---|
33–34 ↗ | (On Diff #19011) | Oh, but it seems the direct ld invocations also use ${OBJCOPY} to convirt to a flat binary like pc98/boot0 used to anyhow. |
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.