[all-commits] [llvm/llvm-project] ac4712: [LoongArch] Use FirstRelocationKind to remove ELFO...

Fangrui Song via All-commits all-commits at lists.llvm.org
Tue Apr 15 23:56:12 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ac4712482e3ff886eee7c044dd33dd4b5d648036
      https://github.com/llvm/llvm-project/commit/ac4712482e3ff886eee7c044dd33dd4b5d648036
  Author: Fangrui Song <i at maskray.me>
  Date:   2025-04-15 (Tue, 15 Apr 2025)

  Changed paths:
    M llvm/include/llvm/MC/MCFixup.h
    M llvm/lib/MC/ELFObjectWriter.cpp
    M llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.cpp
    M llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchELFObjectWriter.cpp
    M llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchFixupKinds.h

  Log Message:
  -----------
  [LoongArch] Use FirstRelocationKind to remove ELFObjectWriter::recordRelocation special case

The current implementation of R_LARCH_SUB{8,16,32,64} and TLS relocation types relies on fixup kinds FirstLiteralRelocationKind + offset (originally intended for .reloc directives). While this is clever and prevents switch cases like

```
case fixup_...sub8:
  return ELF::R_LARCH_SUB8;
```

it needs revision.

GNU Assembler treats .reloc directives differently from standard relocations, notably by skipping

* Skipping STT_SECTION adjustments (when a referenced symbol is local and satisfies certain conditions, it can be redirected to a section symbol).
* Skipping STT_TLS symbol type setting for TLS relocations.

Encode relocatin type t with FirstRelocationKind+t instead of
FirstLiteralRelocationKind+t. The new value is less than
FirstLiteralRelocationKind and will not be treated as a .reloc
directive.

Close #135521



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