[PATCH] D37960: [mips] Fix relocation record format and ELF header for N32 ABI

Simon Atanasyan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 19 11:30:45 PDT 2017


atanasyan added inline comments.


================
Comment at: test/MC/Mips/cpsetup.s:35
 # NXX-NEXT: lui      $gp, 0
-# N32-NEXT: R_MIPS_HI16/R_MIPS_NONE/R_MIPS_NONE __gnu_local_gp
+# N32-NEXT: R_MIPS_HI16 __gnu_local_gp
 # N64-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_HI16  __cerror
----------------
sdardis wrote:
> FIXME: this is actually the expansion of .cpsetup for -mno-shared. N32 in -mshared mode generates the same 3-in-1 relocation sequence as N64.
> 
> See my comments on https://reviews.llvm.org/D21131
  - Does it really generates 3-in-1 relocation where three relocations are packed into the single relocation record? As far as I understand N32 ABI uses for that a series of relocations targeted the same place in the code. For example this code:
```
  .globl  foo
  .ent  foo
foo:
  lui   $gp, %hi(%neg(%gp_rel(foo+4)))
  addiu $gp, $gp, %lo(%neg(%gp_rel(foo+4)))
  daddu $gp, $gp, $25
  .end  foo
```
generates the following relocations:
```
Relocations [
  Section (3) .rela.text {
    0x0 R_MIPS_GPREL16 foo 0x4
    0x0 R_MIPS_SUB - 0x0
    0x0 R_MIPS_HI16 - 0x0
    0x4 R_MIPS_GPREL16 foo 0x4
    0x4 R_MIPS_SUB - 0x0
    0x4 R_MIPS_LO16 - 0x0
  }
```

  - Do you suggest to fix assemble code in the test case and/or write a comment or something else? BTW my next patch fixes relocation generation for the code like `lui   $gp, %hi(%neg(%gp_rel(foo+4)))` in case of N32 ABI.


================
Comment at: test/MC/Mips/elf_header.s:74-76
+# FIXME: llvm-mc -filetype=obj -triple mips64-unknown-linux   -mcpu=mips3    -target-abi=n64                 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,BE,N64,NAN1985,MIPS3    %s
+# FIXME: llvm-mc -filetype=obj -triple mips64-unknown-linux   -mcpu=mips4    -target-abi=n64                 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,BE,N64,NAN1985,MIPS4    %s
+# FIXME: llvm-mc -filetype=obj -triple mips64-unknown-linux   -mcpu=mips5    -target-abi=n64                 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,BE,N64,NAN1985,MIPS5    %s
----------------
sdardis wrote:
> The N64 check prefix for EF_MIPS_PC looks to be spurious here, as llvm-mc is generating non-position independent code as it's an empty file.
> 
> I think that portion of the test (line 136) should be dropped and other tests should be put to catalogue how N64 deals with PIC.
OK


Repository:
  rL LLVM

https://reviews.llvm.org/D37960





More information about the llvm-commits mailing list