[PATCH] D99810: [ifs][elfabi] Merge llvm-elfabi tool into llvm-ifs
Haowei Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 6 20:38:21 PDT 2021
haowei marked 3 inline comments as done.
haowei added a comment.
I will try to split this change.
================
Comment at: clang/lib/Driver/ToolChains/InterfaceStubs.cpp:26
const bool WriteBin = !Args.getLastArg(options::OPT_emit_merged_ifs);
- CmdArgs.push_back(WriteBin ? "write-bin" : "write-ifs");
+ CmdArgs.push_back(WriteBin ? "--output-format=ELF" : "--output-format=IFS");
CmdArgs.push_back("-o");
----------------
phosek wrote:
> Do we know whether the binary output format for the current target is ELF? Shouldn't we check it first?
I tried following way:
```
const bool WriteBin = !Args.getLastArg(options::OPT_emit_merged_ifs);
if (WriteBin) {
llvm::Triple::OSType OS = C.getDefaultToolChain().getEffectiveTriple().getOS();
switch(OS) {
case llvm::Triple::OSType::DragonFly:
case llvm::Triple::OSType::Fuchsia:
case llvm::Triple::OSType::KFreeBSD:
case llvm::Triple::OSType::Linux:
case llvm::Triple::OSType::Lv2:
case llvm::Triple::OSType::NetBSD:
case llvm::Triple::OSType::OpenBSD:
case llvm::Triple::OSType::Solaris:
case llvm::Triple::OSType::Haiku:
case llvm::Triple::OSType::Minix:
case llvm::Triple::OSType::NaCl:
case llvm::Triple::OSType::PS4:
case llvm::Triple::OSType::ELFIAMCU:
case llvm::Triple::OSType::Contiki:
case llvm::Triple::OSType::Hurd:
CmdArgs.push_back("--output-format=ELF");
break;
// default:
// // Not adding "--output-format" will cause llvm-ifs to crash.
}
} else {
CmdArgs.push_back("--output-format=IFS");
}
```
but it does not work. It looks like the Toolchain object is not properly constructed in this stage, which makes it difficult to determine the target of current clang invocation. Do you have any suggestions?
================
Comment at: llvm/include/llvm/InterfaceStub/IFSStub.h:28-52
+enum class IFSSymbolType {
NoType = ELF::STT_NOTYPE,
Object = ELF::STT_OBJECT,
Func = ELF::STT_FUNC,
TLS = ELF::STT_TLS,
// Type information is 4 bits, so 16 is safely out of range.
----------------
phosek wrote:
> Since IFS is supposed to be binary format agnostic, it's a bit confusing to use ELF constants here. Could we instead define these values ourselves and convert them to the corresponding ELF values when generating the stub?
I removed ELF constants and added helper functions.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D99810/new/
https://reviews.llvm.org/D99810
More information about the cfe-commits
mailing list