riscv-software-src / riscv-pk

RISC-V Proxy Kernel
Other
579 stars 306 forks source link

bbl: change-address not recognized by llvm-objcopy #267

Open ZenithalHourlyRate opened 2 years ago

ZenithalHourlyRate commented 2 years ago

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)

aswaterman commented 2 years ago

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.

MaskRay commented 2 years ago

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.