[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 04:26:45 PST 2022


quic-subhkedi created this revision.
quic-subhkedi added reviewers: bcain, kparzysz.
Herald added a subscriber: kristof.beyls.
Herald added a reviewer: jhenderson.
Herald added a project: All.
quic-subhkedi requested review of this revision.
Herald added subscribers: llvm-commits, MaskRay.
Herald added a project: LLVM.

The address value printed for the symbol "foo" in the added test case using llvm-nm is 1002 which is one byte short of the expected value of 1003. The GNU nm prints the expected value of 1003 on the generated object file in the added test case

The aim is to either fix this and align with GNU tools output.


Repository:
  rG LLVM Github Monorepo

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 address
+## to reflect 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
\ No newline at end of file
Index: llvm/include/llvm/Object/ELFObjectFile.h
===================================================================
--- llvm/include/llvm/Object/ELFObjectFile.h
+++ llvm/include/llvm/Object/ELFObjectFile.h
@@ -559,7 +559,7 @@
 
   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) &&
+  if ((Header.e_machine == ELF::EM_MIPS) &&
       (*SymOrErr)->getType() == ELF::STT_FUNC)
     Ret &= ~1;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139097.479239.patch
Type: text/x-patch
Size: 1382 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221201/4c0238ec/attachment.bin>


More information about the llvm-commits mailing list