diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-03-31 19:00:23 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-03-31 19:00:23 +0000 |
commit | ee1c342ef97afeccd38eddacdb8bea8d99ed4070 (patch) | |
tree | 09f81256648d487c46497d0ea2d5ef19bf4d9b3e | |
parent | c0d21793be6d24d520562fc3b7f48e93b9a496f3 (diff) | |
download | bcm5719-llvm-ee1c342ef97afeccd38eddacdb8bea8d99ed4070.tar.gz bcm5719-llvm-ee1c342ef97afeccd38eddacdb8bea8d99ed4070.zip |
Don't relocate with sections if there might be a paired relocation.
llvm-svn: 205240
-rw-r--r-- | llvm/include/llvm/Support/ELF.h | 3 | ||||
-rw-r--r-- | llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp | 20 | ||||
-rw-r--r-- | llvm/test/MC/Mips/xgot.s | 2 |
3 files changed, 22 insertions, 3 deletions
diff --git a/llvm/include/llvm/Support/ELF.h b/llvm/include/llvm/Support/ELF.h index 2ac42591436..7b10ebd23f2 100644 --- a/llvm/include/llvm/Support/ELF.h +++ b/llvm/include/llvm/Support/ELF.h @@ -880,6 +880,9 @@ enum { R_MIPS_TLS_TPREL_HI16 = 49, R_MIPS_TLS_TPREL_LO16 = 50, R_MIPS_GLOB_DAT = 51, + R_MIPS16_GOT16 = 102, + R_MIPS16_HI16 = 104, + R_MIPS16_LO16 = 105, R_MIPS_COPY = 126, R_MIPS_JUMP_SLOT = 127, R_MICROMIPS_26_S1 = 133, diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp index f933962d664..794978b30bf 100644 --- a/llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp +++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp @@ -206,9 +206,25 @@ MipsELFObjectWriter::needsRelocateWithSymbol(unsigned Type) const { default: return true; - case ELF::R_MIPS_26: - case ELF::R_MIPS_LO16: + case ELF::R_MIPS_GOT16: + case ELF::R_MIPS16_GOT16: + case ELF::R_MICROMIPS_GOT16: + llvm_unreachable("Should have been handled already"); + + // These relocations might be paired with another relocation. The pairing is + // done by the static linker by matching the symbol. Since we only see one + // relocation at a time, we have to force them to relocate with a symbol to + // avoid ending up with a pair where one points to a section and another + // points to a symbol. case ELF::R_MIPS_HI16: + case ELF::R_MIPS16_HI16: + case ELF::R_MICROMIPS_HI16: + case ELF::R_MIPS_LO16: + case ELF::R_MIPS16_LO16: + case ELF::R_MICROMIPS_LO16: + return true; + + case ELF::R_MIPS_26: case ELF::R_MIPS_32: case ELF::R_MIPS_64: case ELF::R_MIPS_GPREL16: diff --git a/llvm/test/MC/Mips/xgot.s b/llvm/test/MC/Mips/xgot.s index 13e1b7e733e..30848066ce3 100644 --- a/llvm/test/MC/Mips/xgot.s +++ b/llvm/test/MC/Mips/xgot.s @@ -11,7 +11,7 @@ // CHECK: 0x24 R_MIPS_CALL_HI16 printf // CHECK: 0x2C R_MIPS_GOT16 $.str // CHECK: 0x30 R_MIPS_CALL_LO16 printf -// CHECK: 0x38 R_MIPS_LO16 .rodata.str1.1 +// CHECK: 0x38 R_MIPS_LO16 $.str // CHECK: ] .text |