Index: ELF/Config.h =================================================================== --- ELF/Config.h +++ ELF/Config.h @@ -10,6 +10,7 @@ #ifndef LLD_ELF_CONFIG_H #define LLD_ELF_CONFIG_H +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/MapVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/ELF.h" @@ -30,6 +31,11 @@ ELF64BEKind }; +struct BuildIdBuilder { + void (*write)(uint8_t *Buf, std::vector> &Inputs); + size_t Size; +}; + // This struct contains the global configuration for the linker. // Most fields are direct mapping from the command line options // and such fields have the same name as the corresponding options. @@ -54,7 +60,6 @@ bool AsNeeded = false; bool Bsymbolic; bool BsymbolicFunctions; - bool BuildId; bool Demangle = true; bool DiscardAll; bool DiscardLocals; @@ -82,6 +87,7 @@ bool ZNow; bool ZOrigin; bool ZRelro; + BuildIdBuilder *BuildId = nullptr; ELFKind EKind = ELFNoneKind; uint16_t EMachine = llvm::ELF::EM_NONE; uint64_t EntryAddr = -1; Index: ELF/Driver.h =================================================================== --- ELF/Driver.h +++ ELF/Driver.h @@ -57,6 +57,9 @@ std::string searchLibrary(StringRef Path); std::string buildSysrootedPath(llvm::StringRef Dir, llvm::StringRef File); +extern BuildIdBuilder BuildIdFnv1; +extern BuildIdBuilder BuildIdMd5; + } // namespace elf } // namespace lld Index: ELF/Driver.cpp =================================================================== --- ELF/Driver.cpp +++ ELF/Driver.cpp @@ -223,7 +223,6 @@ Config->AllowMultipleDefinition = Args.hasArg(OPT_allow_multiple_definition); Config->Bsymbolic = Args.hasArg(OPT_Bsymbolic); Config->BsymbolicFunctions = Args.hasArg(OPT_Bsymbolic_functions); - Config->BuildId = Args.hasArg(OPT_build_id); Config->Demangle = !Args.hasArg(OPT_no_demangle); Config->DiscardAll = Args.hasArg(OPT_discard_all); Config->DiscardLocals = Args.hasArg(OPT_discard_locals); @@ -277,6 +276,17 @@ error("Unknown hash style: " + S); } + // Parse --build-id or --build-id=