From: Nikola Prica Date: Wed, 10 Jul 2019 18:58:05 +0000 (+0000) Subject: Revert "[ELF] Loose a condition for relocation with a symbol" X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3eed20c813a231ebe4a74b3a75b9867f19b12689;p=llvm Revert "[ELF] Loose a condition for relocation with a symbol" This reverts commit 8507eca1647118e73435b0ce1de8a1952a021d01. Reveting due to some suspicious failurse in santizer-x86_64-linux. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@365685 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp index e20af8de0c3..2c68723a12f 100644 --- a/lib/MC/ELFObjectWriter.cpp +++ b/lib/MC/ELFObjectWriter.cpp @@ -1396,6 +1396,11 @@ bool ELFObjectWriter::shouldRelocateWithSymbol(const MCAssembler &Asm, if (Flags & ELF::SHF_MERGE) { if (C != 0) return true; + + // It looks like gold has a bug (http://sourceware.org/PR16794) and can + // only handle section relocations to mergeable sections if using RELA. + if (!hasRelocationAddend()) + return true; } // Most TLS relocations use a got, so they need the symbol. Even those that diff --git a/test/MC/ELF/basic-elf-32.s b/test/MC/ELF/basic-elf-32.s index bddb3954ec8..f2303e183da 100644 --- a/test/MC/ELF/basic-elf-32.s +++ b/test/MC/ELF/basic-elf-32.s @@ -46,9 +46,9 @@ main: # @main // CHECK: Relocations [ // CHECK: Section {{.*}} .rel.text { -// CHECK: 0x6 R_386_32 .rodata.str1.1 0x0 +// CHECK: 0x6 R_386_32 .L.str1 // CHECK: 0xB R_386_PC32 puts -// CHECK: 0x12 R_386_32 .rodata.str1.1 0x0 +// CHECK: 0x12 R_386_32 .L.str2 // CHECK: 0x17 R_386_PC32 puts // CHECK: } // CHECK: ] diff --git a/test/MC/ELF/compression.s b/test/MC/ELF/compression.s index 9bc5c0ecc69..93a77b3fcbd 100644 --- a/test/MC/ELF/compression.s +++ b/test/MC/ELF/compression.s @@ -38,7 +38,7 @@ // In x86 32 bit named symbols are used for temporary symbols in merge // sections, so make sure we handle symbols inside compressed sections -// 386-SYMBOLS-GNU: Name: .zdebug_str +// 386-SYMBOLS-GNU: Name: .Linfo_string0 // 386-SYMBOLS-GNU-NOT: } // 386-SYMBOLS-GNU: Section: .zdebug_str @@ -73,7 +73,7 @@ // ZLIB-STYLE-FLAGS32-NEXT: AddressAlignment: 4 // ZLIB-STYLE-FLAGS64-NEXT: AddressAlignment: 8 -// 386-SYMBOLS-ZLIB: Name: .debug_str +// 386-SYMBOLS-ZLIB: Name: .Linfo_string0 // 386-SYMBOLS-ZLIB-NOT: } // 386-SYMBOLS-ZLIB: Section: .debug_str diff --git a/test/MC/ELF/relocation-386.s b/test/MC/ELF/relocation-386.s index 84114083745..e2c4e1073ad 100644 --- a/test/MC/ELF/relocation-386.s +++ b/test/MC/ELF/relocation-386.s @@ -8,7 +8,7 @@ // I386: Format: ELF32-i386 // CHECK: Relocations [ // CHECK-NEXT: Section {{.*}} .rel.text { -// CHECK-NEXT: 0x2 R_386_GOTOFF .rodata.str1.16 0x0 +// CHECK-NEXT: 0x2 R_386_GOTOFF .Lfoo 0x0 // CHECK-NEXT: 0x{{[^ ]+}} R_386_PLT32 bar2 0x0 // CHECK-NEXT: 0x{{[^ ]+}} R_386_GOTPC _GLOBAL_OFFSET_TABLE_ 0x0 // Relocation 3 (bar3@GOTOFF) is done with symbol 7 (bss) diff --git a/test/MC/Mips/elf-relsym.s b/test/MC/Mips/elf-relsym.s index d42569d1645..e0b384ca527 100644 --- a/test/MC/Mips/elf-relsym.s +++ b/test/MC/Mips/elf-relsym.s @@ -4,10 +4,16 @@ // CHECK: Symbols [ // CHECK: Symbol { -// CHECK: Name: .rodata.cst8 +// CHECK: Name: $.str // CHECK: } // CHECK: Symbol { -// CHECK: Name: .rodata.str1.1 +// CHECK: Name: $.str1 +// CHECK: } +// CHECK: Symbol { +// CHECK: Name: $CPI0_0 +// CHECK: } +// CHECK: Symbol { +// CHECK: Name: $CPI0_1 // CHECK: } // CHECK: ] diff --git a/test/MC/Mips/xgot.s b/test/MC/Mips/xgot.s index 1e1b468d7b1..9c64db749fd 100644 --- a/test/MC/Mips/xgot.s +++ b/test/MC/Mips/xgot.s @@ -10,8 +10,8 @@ // CHECK: 0x1C R_MIPS_GOT_LO16 ext_1 // CHECK: 0x24 R_MIPS_CALL_HI16 printf // CHECK: 0x30 R_MIPS_CALL_LO16 printf -// CHECK: 0x2C R_MIPS_GOT16 .rodata.str1.1 0x0 -// CHECK: 0x38 R_MIPS_LO16 .rodata.str1.1 0x0 +// CHECK: 0x2C R_MIPS_GOT16 $.str +// CHECK: 0x38 R_MIPS_LO16 $.str // CHECK: ] .text