[PATCH] D155732: [MC][COFF][AArch64] Avoid incorrect IMAGE_REL_ARM64_BRANCH26 relocations.
    Saleem Abdulrasool via Phabricator via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Tue Aug  8 13:57:13 PDT 2023
    
    
  
compnerd added a comment.
In D155732#4570674 <https://reviews.llvm.org/D155732#4570674>, @efriedma wrote:
> In D155732#4570643 <https://reviews.llvm.org/D155732#4570643>, @compnerd wrote:
>
>>> I don't think that we can directly compare what we do to masm; we support an assembler dialect which is not masm, and that includes branching where the destination is an offset from a symbol. Given that, I think we need this logic in WinCOFFObjectWriter, whether or not we emit all temporary symbols. (The change in AArch64AsmBackend.cpp is necessary either way.)
>>
>> I guess the piece that I'm wondering is why we would need that if the local symbol is available because the label is preserved, the linker should be able to resolve the symbol relative offset and then discard the temporary symbol I thought.  What condition am I overlooking?
>
> I was thinking of the case of branching to "x+4", or something like that, where there isn't any existing symbol at the offset in question.  We could forbid that, I guess, but it seems like that just shifts complexity elsewhere.
Right, I was thinking that we would have a(n extra) label at that point so the offset is always 0.  We would generate a synthetic symbol for any case where the user is writing out an offset from a symbol.
e.g.
    .def sym
      .scl 2
      .type 32
    .endif
  sym:
    nop
    nop
  $LN$reloc:
    .long $LN$reloc
    ret
would be equivalent to:
    .def sym
      .scl 2
      .type 32
    .endif
  sym:
    nop
    nop
    .long .sym + 4
    ret
CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D155732/new/
https://reviews.llvm.org/D155732
    
    
More information about the llvm-commits
mailing list