Issue 135521
Summary [LoongArch] ADD/SUB and TLS relocation should move away from `FirstLiteralRelocationKind + offset`
Labels backend:loongarch
Assignees
Reporter MaskRay
    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

```c
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.

I intend to fix a `.reloc` behavior in ELFObjectWriter (https://github.com/llvm/llvm-project/pull/135519) and notice that `llvm/test/MC/LoongArch/Relocations/relax-addsub.s` (#76433) will be broken. @MQ-mengqing 
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to