[llvm] 382df1c - Revert "Reland D64327 [MC][ELF] Allow STT_SECTION referencing SHF_MERGE on REL targets"
Mitch Phillips via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 7 10:59:39 PDT 2020
Author: Mitch Phillips
Date: 2020-08-07T10:56:33-07:00
New Revision: 382df1c6744d09e9f3362f9743788574913980b4
URL: https://github.com/llvm/llvm-project/commit/382df1c6744d09e9f3362f9743788574913980b4
DIFF: https://github.com/llvm/llvm-project/commit/382df1c6744d09e9f3362f9743788574913980b4.diff
LOG: Revert "Reland D64327 [MC][ELF] Allow STT_SECTION referencing SHF_MERGE on REL targets"
This reverts commit b497665d98ad5026b1d3d67d5793a28fefe27bea.
Spent some time trying to reproduce this locally, reverting in a
desparate attempt to fix the sanitizer buildbot:
- http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/28828
I don't know exactly why or how this patch breaks the bots, but it seems
pretty concrete that it's the culprit.
Added:
Modified:
llvm/cmake/modules/AddLLVM.cmake
llvm/lib/MC/ELFObjectWriter.cpp
llvm/test/MC/ELF/basic-elf-32.s
llvm/test/MC/ELF/compression.s
llvm/test/MC/ELF/relocation-386.s
llvm/test/MC/Mips/elf-relsym.s
llvm/test/MC/Mips/xgot.s
Removed:
################################################################################
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 2ff5c29c6b1a..ac3d5c8e3c7d 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -222,13 +222,8 @@ function(add_link_opts target_name)
# Pass -O3 to the linker. This enabled
diff erent optimizations on
diff erent
# linkers.
if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin|SunOS|AIX" OR WIN32))
- # Before binutils 2.34, gold -O2 and above did not correctly handle R_386_GOTOFF to
- # SHF_MERGE|SHF_STRINGS sections: https://sourceware.org/bugzilla/show_bug.cgi?id=16794
- if(LLVM_LINKER_IS_GOLD)
- set_property(TARGET ${target_name} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,-O1")
- else()
- set_property(TARGET ${target_name} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,-O3")
- endif()
+ set_property(TARGET ${target_name} APPEND_STRING PROPERTY
+ LINK_FLAGS " -Wl,-O3")
endif()
if(LLVM_LINKER_IS_GOLD)
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index b44a36b9713e..494f82558d82 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -1393,6 +1393,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/llvm/test/MC/ELF/basic-elf-32.s b/llvm/test/MC/ELF/basic-elf-32.s
index 1a923106036a..effc363d1c6c 100644
--- a/llvm/test/MC/ELF/basic-elf-32.s
+++ b/llvm/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/llvm/test/MC/ELF/compression.s b/llvm/test/MC/ELF/compression.s
index 9bc5c0ecc699..93a77b3fcbdb 100644
--- a/llvm/test/MC/ELF/compression.s
+++ b/llvm/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/llvm/test/MC/ELF/relocation-386.s b/llvm/test/MC/ELF/relocation-386.s
index b9bf9b6a00c1..4273750a4192 100644
--- a/llvm/test/MC/ELF/relocation-386.s
+++ b/llvm/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 at GOTOFF) is done with symbol 7 (bss)
diff --git a/llvm/test/MC/Mips/elf-relsym.s b/llvm/test/MC/Mips/elf-relsym.s
index d19b4e3c4820..b8c2f89e82e6 100644
--- a/llvm/test/MC/Mips/elf-relsym.s
+++ b/llvm/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/llvm/test/MC/Mips/xgot.s b/llvm/test/MC/Mips/xgot.s
index 76490f0dec93..100d25e67223 100644
--- a/llvm/test/MC/Mips/xgot.s
+++ b/llvm/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
More information about the llvm-commits
mailing list