[PATCH] D139097: [ARM] Fix Address value difference for symbol emitted by llvm-nm
Subham Kedia via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 1 05:56:24 PST 2022
quic-subhkedi updated this revision to Diff 479260.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D139097/new/
https://reviews.llvm.org/D139097
Files:
llvm/include/llvm/Object/ELFObjectFile.h
llvm/test/tools/llvm-nm/ARM/address-check.test
Index: llvm/test/tools/llvm-nm/ARM/address-check.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-nm/ARM/address-check.test
@@ -0,0 +1,26 @@
+## Test for function type symbols with odd valued addresses have the correct
+## value on ARM.
+#
+# RUN: yaml2obj %s -o %t
+# RUN: llvm-nm %t | FileCheck %s
+
+!ELF
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_ARM
+ Flags: [ EF_ARM_EABI_VER5 ]
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 0x4
+Symbols:
+ - Name: foo
+ Value: 0x1003
+ Section: .text
+ Type: STT_FUNC
+ Binding: STB_GLOBAL
+
+# CHECK: 00001003 T foo
Index: llvm/include/llvm/Object/ELFObjectFile.h
===================================================================
--- llvm/include/llvm/Object/ELFObjectFile.h
+++ llvm/include/llvm/Object/ELFObjectFile.h
@@ -552,18 +552,7 @@
Expected<const Elf_Sym *> SymOrErr = getSymbol(Symb);
if (!SymOrErr)
report_fatal_error(SymOrErr.takeError());
-
- uint64_t Ret = (*SymOrErr)->st_value;
- if ((*SymOrErr)->st_shndx == ELF::SHN_ABS)
- return Ret;
-
- const Elf_Ehdr &Header = EF.getHeader();
- // Clear the ARM/Thumb or microMIPS indicator flag.
- if ((Header.e_machine == ELF::EM_ARM || Header.e_machine == ELF::EM_MIPS) &&
- (*SymOrErr)->getType() == ELF::STT_FUNC)
- Ret &= ~1;
-
- return Ret;
+ return (*SymOrErr)->st_value;
}
template <class ELFT>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139097.479260.patch
Type: text/x-patch
Size: 1615 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221201/ed54bafd/attachment.bin>
More information about the llvm-commits
mailing list