Reproduction https://github.com/xiaoxiangmoe/issue-llvm-lld-oformat-binary-compability
linker.ld:
ENTRY(main);
SECTIONS
{
. = 0x7C00;
.text : AT(0x7C00)
{
*(__start);
_text = .;
*(.text);
_text_end = .;
}
.sig : AT(0x7DFE)
{
SHORT(0xaa55);
}
}
When using LLD without --oformat=binary
The result is
$ hexdump -C dist-lld-elf/boot.bin
00000000 eb fe cc cc 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
00000200
it works well
When using LLD with --oformat=binary
The result is
$ hexdump -C dist-lld-binary/boot.bin
00000000 eb fe cc cc 55 aa |....U.|
00000006
The AT section attribute is not working at all.