[lld] 018a484 - [llvm-objdump] Map STT_TLS to ST_Other (previously ST_Data)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 17 23:17:28 PST 2021
Author: Fangrui Song
Date: 2021-02-17T23:17:20-08:00
New Revision: 018a484cd26d72fb4c9e7fd75e5f5bc7838dfc73
URL: https://github.com/llvm/llvm-project/commit/018a484cd26d72fb4c9e7fd75e5f5bc7838dfc73
DIFF: https://github.com/llvm/llvm-project/commit/018a484cd26d72fb4c9e7fd75e5f5bc7838dfc73.diff
LOG: [llvm-objdump] Map STT_TLS to ST_Other (previously ST_Data)
ST_Data is used to model BFD `BFD_OBJECT`.
A STT_TLS symbol does not have the `BFD_OBJECT` flag in BFD.
This makes sense because a STT_TLS symbol is like in a different address space,
normal data/object properties do not apply on them.
With this change, a STT_TLS symbol will not be displayed as 'O'.
This new behavior matches objdump.
Differential Revision: https://reviews.llvm.org/D96735
Added:
Modified:
lld/test/ELF/mips-mgot.s
lld/test/ELF/mips-tls-64.s
lld/test/ELF/mips-tls-hilo.s
lld/test/ELF/mips-tls-static-64.s
lld/test/ELF/mips-tls-static.s
lld/test/ELF/mips-tls.s
llvm/include/llvm/Object/ELFObjectFile.h
llvm/test/tools/llvm-objdump/ELF/symbol-table.test
Removed:
################################################################################
diff --git a/lld/test/ELF/mips-mgot.s b/lld/test/ELF/mips-mgot.s
index 55741e4107a5..6978b5d9623b 100644
--- a/lld/test/ELF/mips-mgot.s
+++ b/lld/test/ELF/mips-mgot.s
@@ -15,10 +15,10 @@
# RUN: llvm-readobj -r --dyn-syms -A %t.so | FileCheck -check-prefix=GOT %s
# CHECK: SYMBOL TABLE:
-# CHECK: 00000000 l O .tdata 00000000 loc0
+# CHECK: 00000000 l .tdata 00000000 loc0
# CHECK: [[FOO0:[0-9a-f]+]] g .text 00000000 foo0
-# CHECK: 00000000 g O .tdata 00000000 tls0
-# CHECK: 00000004 g O .tdata 00000000 tls1
+# CHECK: 00000000 g .tdata 00000000 tls0
+# CHECK: 00000004 g .tdata 00000000 tls1
# CHECK: [[FOO2:[0-9a-f]+]] g .text 00000000 foo2
# CHECK: Contents of section .got:
diff --git a/lld/test/ELF/mips-tls-64.s b/lld/test/ELF/mips-tls-64.s
index 2ae906f84400..a3657cea51c0 100644
--- a/lld/test/ELF/mips-tls-64.s
+++ b/lld/test/ELF/mips-tls-64.s
@@ -21,9 +21,9 @@
# RUN: | FileCheck -check-prefix=DIS-SO %s
# RUN: llvm-readobj -r -A %t-out.so | FileCheck -check-prefix=SO %s
-# DIS: 0000000000000000 l O .tdata 0000000000000000 loc
-# DIS: 0000000000000000 O *UND* 0000000000000000 foo
-# DIS: 0000000000000004 g O .tdata 0000000000000000 bar
+# DIS: 0000000000000000 l .tdata 0000000000000000 loc
+# DIS: 0000000000000000 *UND* 0000000000000000 foo
+# DIS: 0000000000000004 g .tdata 0000000000000000 bar
# DIS: Contents of section .got:
# DIS-NEXT: 30000 00000000 00000000 80000000 00000000
diff --git a/lld/test/ELF/mips-tls-hilo.s b/lld/test/ELF/mips-tls-hilo.s
index 92cf71be5ecc..5596e9e6f924 100644
--- a/lld/test/ELF/mips-tls-hilo.s
+++ b/lld/test/ELF/mips-tls-hilo.s
@@ -12,7 +12,7 @@
# ERR: error: relocation R_MIPS_TLS_TPREL_HI16 against loc0 cannot be used with -shared
# ERR: error: relocation R_MIPS_TLS_TPREL_LO16 against loc0 cannot be used with -shared
-# DIS: 00000000 l O .tdata 00000000 loc0
+# DIS: 00000000 l .tdata 00000000 loc0
# DIS: <__start>:
# DIS-NEXT: addiu $2, $3, 0
diff --git a/lld/test/ELF/mips-tls-static-64.s b/lld/test/ELF/mips-tls-static-64.s
index 1e8b14db2329..090719ad456e 100644
--- a/lld/test/ELF/mips-tls-static-64.s
+++ b/lld/test/ELF/mips-tls-static-64.s
@@ -8,7 +8,7 @@
# CHECK: SYMBOL TABLE:
# CHECK: [[TGA:[0-9a-f]{8}]] g .text 0000000000000000 __tls_get_addr
-# CHECK: 0000000000000000 g O .tdata 0000000000000000 tls1
+# CHECK: 0000000000000000 g .tdata 0000000000000000 tls1
#
# CHECK: Contents of section .data:
# CHECK-NEXT: {{.*}} [[TGA]] ffffffff ffff8004 ffffffff
diff --git a/lld/test/ELF/mips-tls-static.s b/lld/test/ELF/mips-tls-static.s
index d489200ea7fc..136066470728 100644
--- a/lld/test/ELF/mips-tls-static.s
+++ b/lld/test/ELF/mips-tls-static.s
@@ -7,7 +7,7 @@
# RUN: llvm-objdump -s -t %t.exe | FileCheck %s
# CHECK: SYMBOL TABLE:
-# CHECK: 00000000 g O .tdata 00000000 tls1
+# CHECK: 00000000 g .tdata 00000000 tls1
# CHECK: [[TGA:[0-9a-f]+]] g .text 00000000 __tls_get_addr
#
# CHECK: Contents of section .data:
diff --git a/lld/test/ELF/mips-tls.s b/lld/test/ELF/mips-tls.s
index e7882687dfc8..4463ec114d48 100644
--- a/lld/test/ELF/mips-tls.s
+++ b/lld/test/ELF/mips-tls.s
@@ -21,9 +21,9 @@
# RUN: | FileCheck -check-prefix=DIS-SO %s
# RUN: llvm-readobj -r -A %t-out.so | FileCheck -check-prefix=SO %s
-# DIS: 00000000 l O .tdata 00000000 loc
-# DIS: 00000000 O *UND* 00000000 foo
-# DIS: 00000004 g O .tdata 00000000 bar
+# DIS: 00000000 l .tdata 00000000 loc
+# DIS: 00000000 *UND* 00000000 foo
+# DIS: 00000004 g .tdata 00000000 bar
# DIS: Contents of section .got:
# DIS-NEXT: 30000 00000000 80000000 00000000 ffff9004
diff --git a/llvm/include/llvm/Object/ELFObjectFile.h b/llvm/include/llvm/Object/ELFObjectFile.h
index fed53eef68c3..0999d4b25d2d 100644
--- a/llvm/include/llvm/Object/ELFObjectFile.h
+++ b/llvm/include/llvm/Object/ELFObjectFile.h
@@ -670,8 +670,8 @@ ELFObjectFile<ELFT>::getSymbolType(DataRefImpl Symb) const {
return SymbolRef::ST_Function;
case ELF::STT_OBJECT:
case ELF::STT_COMMON:
- case ELF::STT_TLS:
return SymbolRef::ST_Data;
+ case ELF::STT_TLS:
default:
return SymbolRef::ST_Other;
}
diff --git a/llvm/test/tools/llvm-objdump/ELF/symbol-table.test b/llvm/test/tools/llvm-objdump/ELF/symbol-table.test
index 98196bf63018..507641ee0f6d 100644
--- a/llvm/test/tools/llvm-objdump/ELF/symbol-table.test
+++ b/llvm/test/tools/llvm-objdump/ELF/symbol-table.test
@@ -14,7 +14,7 @@
# CHECK-NEXT:0000000000000000 g O .data 0000000000000010 object
# CHECK-NEXT:0000000000000000 g F .text 000000000000000f func
# CHECK-NEXT:0000000000000000 g O *COM* 0000000000000000 common
-# CHECK-NEXT:0000000000000000 g O .data 0000000000000000 tls
+# CHECK-NEXT:0000000000000000 g .data 0000000000000000 tls
# CHECK-NEXT:0000000000000000 g i .text 0000000000000000 ifunc
# CHECK-NEXT:0000000000000000 g .text 0000000000000000 invalid_type
# CHECK-NEXT:0000000000000000 g .text 0000000000000000 STT_HIOS
More information about the llvm-commits
mailing list