diff options
author | Alex Brachet <abrachet@google.com> | 2022-05-14 18:50:20 +0000 |
---|---|---|
committer | Alex Brachet <abrachet@google.com> | 2022-05-14 18:50:20 +0000 |
commit | a74d9e74e5f97640ed0727fcd363c165209dfbf1 (patch) | |
tree | 6aca89143c1e0be7dd8df5f77f060f51c6124606 /llvm/lib/InterfaceStub | |
parent | 60e5fd00cde3e98cc2b2b8769b5cef23c8faa1d7 (diff) | |
download | llvm-a74d9e74e5f97640ed0727fcd363c165209dfbf1.zip llvm-a74d9e74e5f97640ed0727fcd363c165209dfbf1.tar.gz llvm-a74d9e74e5f97640ed0727fcd363c165209dfbf1.tar.bz2 |
[ifs] Add --strip-size flag
st_size may not be of importance to the abi if you are not using
copy relocations. This is helpful when you want to check the abi
of a shared object both when instrumented and not because asan
will increase the size of objects to include the redzone.
Differential revision: https://reviews.llvm.org/D124792
Diffstat (limited to 'llvm/lib/InterfaceStub')
-rw-r--r-- | llvm/lib/InterfaceStub/ELFObjHandler.cpp | 3 | ||||
-rw-r--r-- | llvm/lib/InterfaceStub/IFSHandler.cpp | 11 |
2 files changed, 8 insertions, 6 deletions
diff --git a/llvm/lib/InterfaceStub/ELFObjHandler.cpp b/llvm/lib/InterfaceStub/ELFObjHandler.cpp index 7420e15..6f37cf6 100644 --- a/llvm/lib/InterfaceStub/ELFObjHandler.cpp +++ b/llvm/lib/InterfaceStub/ELFObjHandler.cpp @@ -217,7 +217,8 @@ public: // time as long as it is not SHN_UNDEF. Set shndx to 1, which // points to ".dynsym". uint16_t Shndx = Sym.Undefined ? SHN_UNDEF : 1; - DynSym.Content.add(DynStr.Content.getOffset(Sym.Name), Sym.Size, Bind, + uint64_t Size = Sym.Size ? *Sym.Size : 0; + DynSym.Content.add(DynStr.Content.getOffset(Sym.Name), Size, Bind, convertIFSSymbolTypeToELF(Sym.Type), 0, Shndx); } DynSym.Size = DynSym.Content.getSize(); diff --git a/llvm/lib/InterfaceStub/IFSHandler.cpp b/llvm/lib/InterfaceStub/IFSHandler.cpp index 92c8830..4a784c7 100644 --- a/llvm/lib/InterfaceStub/IFSHandler.cpp +++ b/llvm/lib/InterfaceStub/IFSHandler.cpp @@ -118,11 +118,12 @@ template <> struct MappingTraits<IFSSymbol> { IO.mapRequired("Type", Symbol.Type); // The need for symbol size depends on the symbol type. if (Symbol.Type == IFSSymbolType::NoType) { - IO.mapOptional("Size", Symbol.Size, (uint64_t)0); - } else if (Symbol.Type == IFSSymbolType::Func) { - Symbol.Size = 0; - } else { - IO.mapRequired("Size", Symbol.Size); + // Size is None, so we are reading it in, or it is non 0 so we + // should emit it. + if (!Symbol.Size || *Symbol.Size) + IO.mapOptional("Size", Symbol.Size); + } else if (Symbol.Type != IFSSymbolType::Func) { + IO.mapOptional("Size", Symbol.Size); } IO.mapOptional("Undefined", Symbol.Undefined, false); IO.mapOptional("Weak", Symbol.Weak, false); |