riscv-pk icon indicating copy to clipboard operation
riscv-pk copied to clipboard

bbl: change-address not recognized by llvm-objcopy

Open ZenithalHourlyRate opened this issue 3 years ago • 3 comments

In bbl/bbl.mk.in, bbl.bin is built using change-addresses.

$(OBJCOPY) -S -O binary --change-addresses -@MEM_START@ $< $@

However, this is not recognized by llvm-objcopy.

llvm-objcopy: error: unknown argument '--change-addresses'

Instead, GNU binutils objcopy and llvm-objcopy both have an option called --change-start, but I do not know whether this option works as I have not tried bbl under my workflow (my workflow only needs pk thus I have to invoke make pk instead of justmake)

ZenithalHourlyRate avatar Feb 06 '22 12:02 ZenithalHourlyRate

I don't have any way of testing this, either. Until someone can verify a fix for both, assume that you must use GNU objcopy for this.

aswaterman avatar Feb 07 '22 22:02 aswaterman

As an llvm-objcopy contributor: llvm-objcopy does not support --change-addresses/--change-section-address (https://github.com/llvm/llvm-project/issues/44562#issuecomment-981025564). Just changing sh_addr is not difficult to implement, but the option seems to imply some layout changes which are poorly specified. The poor specification and our unawareness of how users (riscv-pk is one, but others may use this differently) use this option makes it somewhat infeasible to implement in llvm-objcopy. I implemented --only-keep-debug by (nearly) fully understanding its behavior. For --change-addresses/--change-section-address, I'd expect something similar.

If your demand can be achieved with a linker script, you may consider a linker script command.

MaskRay avatar Feb 09 '22 00:02 MaskRay