[llvm] [llvm][MC][ARM][Assembly] Emit relocations for ADRs and big-endian targets (PR #73834)

via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 22 04:41:00 PST 2023


bd1976bris wrote:

> Apologies I'm going to be away from a work computer for the next couple of weeks due to holiday, can only leave a few comments for now. 

Thanks for the quick reply. I am also away until the new year now so progress on this will have to wait until then.

>In theory the assembler fixup and the linker relocation are semantically identical, the linker is expected to convert the add into a sub and vice-versa regardless of what the object file uses (https://github.com/llvm/llvm-project/blob/main/lld/ELF/Arch/ARM.cpp#L467C25). If there is an out of range error then something else may have gone wrong. Either the assembler is not writing out the object file correctly, or the linker is not resolving the relocation correctly. Are you able to help with a reproducer either for the assembler or the linker? I think Free BSD uses lld as the linker?

Yes, I believe that FreeBSD supports linking with LLD; I'm unsure as to whether they also support the GNU linkers? @emaste might know more? 

Thanks for the clarification on the relocation behaviour. I'm afraid that my arm/thumb knowledge is very rusty indeed and I didn't spot this in LLD ( was also in a bit of a rush before the holidays) - apologies.

> I agree that it would be good to have the relocation resolved at assembly time if in the same section. From memory this wasn't easy to do for just these relocations in https://github.com/llvm/llvm-project/blob/main/llvm/lib/MC/MCAssembler.cpp#L248. Looking at the history of this problem, there is an epic thread in https://reviews.llvm.org/D72892 which looks like it involved these same BSD source files.

Thanks for the thread link. I'll read it.
 
> While I think doing the extra work to either emit an error message or do the fixup (for just these relocations when the fixup is in the same section) is possible. Given that the assembler/linker combination should work, I'd prefer to get to the bottom of why this case is failing first.

I should be able to come up with a reproducer based on that FreeBSD code. I'll work on supplying that when I get back in the new year.

https://github.com/llvm/llvm-project/pull/73834


More information about the llvm-commits mailing list