[PATCH] D136950: [XCOFF] change the decoding of External symbol's function auxiliary entry in XCOFF32 for llvm-readobj

Digger Lin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 28 07:19:54 PDT 2022


DiggerLin created this revision.
DiggerLin added reviewers: hubert.reinterpretcast, jhenderson, Esme.
Herald added a project: All.
DiggerLin requested review of this revision.
Herald added subscribers: llvm-commits, MaskRay.
Herald added a project: LLVM.

1. llvm-readobj decide whether to decode the external symbol's function auxiliary entry based on whether symbol is function or not currently. and the  XCOFFSymbolRef::isFunction()  do not work properly when -ffunction-sections is enabled. we will not decode the function auxiliary entry  based on the XCOFFSymbolRef::isFunction()

2. we will decode the  the function auxiliary entry  based on following.

According to the https://www.ibm.com/docs/en/aix/7.2?topic=formats-xcoff-object-file-format#XCOFF__c0f91ad419jbau

In XCOFF32, there are only "one csect Auxiliary Entry" and  "a function auxiliary symbol table entry"  for the C_EXT, C_WEAKEXT, and C_HIDEXT Symbols. and By convention, the csect auxiliary entry in an XCOFF32 file must be the last auxiliary entry for any external symbol that has more than one auxiliary entry.

in XCOFF32,  for the C_EXT, C_WEAKEXT, and C_HIDEXT Symbols. if there more than one auxiliary Entries. we look the last one as  csect auxiliary entry. and others auxiliary entries as function entries.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136950

Files:
  llvm/test/tools/llvm-readobj/XCOFF/symbols-invalid.test
  llvm/tools/llvm-readobj/XCOFFDumper.cpp


Index: llvm/tools/llvm-readobj/XCOFFDumper.cpp
===================================================================
--- llvm/tools/llvm-readobj/XCOFFDumper.cpp
+++ llvm/tools/llvm-readobj/XCOFFDumper.cpp
@@ -616,22 +616,13 @@
   case XCOFF::C_EXT:
   case XCOFF::C_WEAKEXT:
   case XCOFF::C_HIDEXT: {
-    if (!SymbolEntRef.isFunction() && NumberOfAuxEntries > 1)
-      reportUniqueWarning("the non-function " +
-                          enumToString(static_cast<uint8_t>(SymbolClass),
-                                       makeArrayRef(SymStorageClass)) +
-                          " symbol at index " + Twine(SymbolIdx) +
-                          " should have only 1 auxiliary entry, i.e. the CSECT "
-                          "auxiliary entry");
-
     // For 32-bit objects, print the function auxiliary symbol table entry. The
     // last one must be a CSECT auxiliary entry.
     // For 64-bit objects, both a function auxiliary entry and an exception
     // auxiliary entry may appear, print them in the loop and skip printing the
     // CSECT auxiliary entry, which will be printed outside the loop.
     for (int I = 1; I <= NumberOfAuxEntries; I++) {
-      if ((I == NumberOfAuxEntries && !Obj.is64Bit()) ||
-          !SymbolEntRef.isFunction())
+      if (I == NumberOfAuxEntries && !Obj.is64Bit())
         break;
 
       uintptr_t AuxAddress = XCOFFObjectFile::getAdvancedSymbolEntryAddress(
Index: llvm/test/tools/llvm-readobj/XCOFF/symbols-invalid.test
===================================================================
--- llvm/test/tools/llvm-readobj/XCOFF/symbols-invalid.test
+++ llvm/test/tools/llvm-readobj/XCOFF/symbols-invalid.test
@@ -1,10 +1,5 @@
 ## Test that we report warnings or dump raw data when symbols are invalid.
 
-# RUN: yaml2obj %s --docnum=1 -o %t1
-# RUN: llvm-readobj --syms %t1 2>&1 | FileCheck %s -DFILE=%t1 --check-prefix=CASE1
-
-# CASE1: warning: '[[FILE]]': the non-function C_EXT symbol at index 1 should have only 1 auxiliary entry, i.e. the CSECT auxiliary entry
-
 --- !XCOFF
 FileHeader:
   MagicNumber: 0x1DF
@@ -14,16 +9,6 @@
     StorageClass:       [[STORAGECLASS='C_EXT']]
     NumberOfAuxEntries: 2
 
-# RUN: yaml2obj %s --docnum=1 -DSTORAGECLASS='C_WEAKEXT' -o %t2
-# RUN: llvm-readobj --syms %t2 2>&1 | FileCheck %s -DFILE=%t2 --check-prefix=CASE2
-
-# CASE2: warning: '[[FILE]]': the non-function C_WEAKEXT symbol at index 1 should have only 1 auxiliary entry, i.e. the CSECT auxiliary entry
-
-# RUN: yaml2obj %s --docnum=1 -DSTORAGECLASS='C_HIDEXT' -o %t3
-# RUN: llvm-readobj --syms %t3 2>&1 | FileCheck %s -DFILE=%t3 --check-prefix=CASE3
-
-# CASE3: warning: '[[FILE]]': the non-function C_HIDEXT symbol at index 1 should have only 1 auxiliary entry, i.e. the CSECT auxiliary entry
-
 # RUN: yaml2obj %s --docnum=1 -DSTORAGECLASS='C_STAT' -o %t4
 # RUN: llvm-readobj --syms %t4 2>&1 | FileCheck %s -DFILE=%t4 --check-prefix=CASE4
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136950.471520.patch
Type: text/x-patch
Size: 2912 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221028/7c8be4ec/attachment.bin>


More information about the llvm-commits mailing list