[PATCH] D124781: [ifs] Fix bug where exclude only excluded when outputting ifs files

Alex Brachet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 2 10:05:52 PDT 2022


abrachet created this revision.
abrachet added a reviewer: haowei.
Herald added a subscriber: jhenderson.
Herald added a project: All.
abrachet requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Now output elf files will also have excluded symbols removed.


https://reviews.llvm.org/D124781

Files:
  llvm/test/tools/llvm-ifs/exclude.test
  llvm/tools/llvm-ifs/llvm-ifs.cpp


Index: llvm/tools/llvm-ifs/llvm-ifs.cpp
===================================================================
--- llvm/tools/llvm-ifs/llvm-ifs.cpp
+++ llvm/tools/llvm-ifs/llvm-ifs.cpp
@@ -429,6 +429,9 @@
   if (StripNeededLibs)
     Stub.NeededLibs.clear();
 
+  if (Error E = filterIFSSyms(Stub, StripUndefined, ExcludeSyms))
+    fatalError(std::move(E));
+
   if (OutputELFFilePath.getNumOccurrences() == 0 &&
       OutputIFSFilePath.getNumOccurrences() == 0 &&
       OutputTBDFilePath.getNumOccurrences() == 0) {
@@ -485,8 +488,6 @@
         stripIFSTarget(Stub, StripIFSTarget, StripIFSArch,
                        StripIFSEndiannessWidth, StripIFSBitWidth);
       }
-      if (Error E = filterIFSSyms(Stub, StripUndefined, ExcludeSyms))
-        fatalError(std::move(E));
       Error IFSWriteError = writeIFS(OutputFilePath.getValue(), Stub);
       if (IFSWriteError)
         fatalError(std::move(IFSWriteError));
@@ -537,8 +538,6 @@
         stripIFSTarget(Stub, StripIFSTarget, StripIFSArch,
                        StripIFSEndiannessWidth, StripIFSBitWidth);
       }
-      if (Error E = filterIFSSyms(Stub, StripUndefined, ExcludeSyms))
-        fatalError(std::move(E));
       Error IFSWriteError = writeIFS(OutputIFSFilePath.getValue(), Stub);
       if (IFSWriteError)
         fatalError(std::move(IFSWriteError));
Index: llvm/test/tools/llvm-ifs/exclude.test
===================================================================
--- llvm/test/tools/llvm-ifs/exclude.test
+++ llvm/test/tools/llvm-ifs/exclude.test
@@ -2,6 +2,9 @@
 
 # RUN: llvm-ifs --input-format=IFS --output-ifs=- --exclude='exclude*' %s | FileCheck %s
 
+# Check that exclude excludes from elf files too.
+# RUN: llvm-ifs %s --output-elf - --exclude='exclude*' | llvm-ifs - --output-ifs - | FileCheck %s
+
 # RUN: llvm-ifs --input-format=IFS --output-ifs=- --exclude='exclude*' \
 # RUN: --strip-undefined %s | FileCheck %s --check-prefix=BOTH
 
@@ -13,6 +16,7 @@
 --- !ifs-v1
 SoName: somelib.so
 IfsVersion: 3.0
+Target: x86_64-unknown-linux-gnu
 Symbols:
   - { Name: dont_exclude, Type: Func, Undefined: true }
   - { Name: exclude_1, Type: Func }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124781.426438.patch
Type: text/x-patch
Size: 2141 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220502/0e3fb750/attachment.bin>


More information about the llvm-commits mailing list