[all-commits] [llvm/llvm-project] c3ff3b: [SPARC][MC] Fix `%gdop_hix22()` and `%gdop_lox10()...

Alex Rønne Petersen via All-commits all-commits at lists.llvm.org
Sun May 4 12:32:39 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c3ff3b2ba36aa638ab6101096799d3960bbd6f17
      https://github.com/llvm/llvm-project/commit/c3ff3b2ba36aa638ab6101096799d3960bbd6f17
  Author: Alex Rønne Petersen <alex at alexrp.com>
  Date:   2025-05-04 (Sun, 04 May 2025)

  Changed paths:
    M llvm/lib/Target/Sparc/MCTargetDesc/SparcAsmBackend.cpp
    M llvm/lib/Target/Sparc/MCTargetDesc/SparcELFObjectWriter.cpp
    M llvm/lib/Target/Sparc/MCTargetDesc/SparcFixupKinds.h
    M llvm/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.cpp
    M llvm/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.h
    M llvm/test/MC/Sparc/relocation-specifier.s

  Log Message:
  -----------
  [SPARC][MC] Fix `%gdop_hix22()` and `%gdop_lox10()` to use correct relocations (#137915)

1bfc5e7 introduced support for `%gdop_hix22()` and `%gdop_lox10()`.
However, it incorrectly mapped them to `R_SPARC_GOTDATA_HIX22` and
`R_SPARC_GOTDATA_LOX10`. They should in fact emit
`R_SPARC_GOTDATA_OP_HIX22` and `R_SPARC_GOTDATA_OP_LOX10`.

This became a problem when assembling glibc's PIC startup code:

```asm
sethi %gdop_hix22(main), %o0
xor %o0, %gdop_lox10(main), %o0
ldx [%l7 + %o0], %o0, %gdop(main)
```

After the `xor`, `%o0` should contain the GOT offset for `main`, but
because of the incorrect relocations, it actually ends up containing the
address of `main`, which of course makes the following `ldx` fail.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list