1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 02:33:06 +01:00

[elfabi] Move llvm-elfabi related code to InterfaceStub library

This change moves elfabi related code to llvm/InterfaceStub library
so it can be shared by multiple llvm tools without causing cyclic
dependencies.

Differential Revision: https://reviews.llvm.org/D85678
This commit is contained in:
Haowei Wu 2020-08-11 11:44:22 -07:00
parent 82307c21a7
commit d8abdb26ca
18 changed files with 82 additions and 49 deletions

View File

@ -13,9 +13,9 @@
#ifndef LLVM_TOOLS_ELFABI_ELFOBJHANDLER_H
#define LLVM_TOOLS_ELFABI_ELFOBJHANDLER_H
#include "llvm/InterfaceStub/ELFStub.h"
#include "llvm/Object/ELFObjectFile.h"
#include "llvm/Object/ELFTypes.h"
#include "llvm/TextAPI/ELF/ELFStub.h"
namespace llvm {

View File

@ -16,8 +16,8 @@
#include "llvm/BinaryFormat/ELF.h"
#include "llvm/Support/VersionTuple.h"
#include <vector>
#include <set>
#include <vector>
namespace llvm {
namespace elfabi {
@ -42,9 +42,7 @@ struct ELFSymbol {
bool Undefined;
bool Weak;
Optional<std::string> Warning;
bool operator<(const ELFSymbol &RHS) const {
return Name < RHS.Name;
}
bool operator<(const ELFSymbol &RHS) const { return Name < RHS.Name; }
};
// A cumulative representation of ELF stubs.

View File

@ -15,8 +15,8 @@
#ifndef LLVM_TEXTAPI_ELF_TBEHANDLER_H
#define LLVM_TEXTAPI_ELF_TBEHANDLER_H
#include "llvm/Support/VersionTuple.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/VersionTuple.h"
#include <memory>
namespace llvm {

View File

@ -3,6 +3,7 @@
add_subdirectory(IR)
add_subdirectory(FuzzMutate)
add_subdirectory(InterfaceStub)
add_subdirectory(IRReader)
add_subdirectory(CodeGen)
add_subdirectory(BinaryFormat)

View File

@ -0,0 +1,8 @@
add_llvm_component_library(LLVMInterfaceStub
ELFObjHandler.cpp
ELFStub.cpp
TBEHandler.cpp
ADDITIONAL_HEADER_DIRS
"${LLVM_MAIN_INCLUDE_DIR}/llvm/InterfaceStub"
)

View File

@ -6,14 +6,14 @@
//
//===-----------------------------------------------------------------------===/
#include "ELFObjHandler.h"
#include "llvm/InterfaceStub/ELFObjHandler.h"
#include "llvm/InterfaceStub/ELFStub.h"
#include "llvm/Object/Binary.h"
#include "llvm/Object/ELFObjectFile.h"
#include "llvm/Object/ELFTypes.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/TextAPI/ELF/ELFStub.h"
using llvm::MemoryBufferRef;
using llvm::object::ELFObjectFile;
@ -128,16 +128,14 @@ static Error populateDynamic(DynamicEntries &Dyn,
"Couldn't locate dynamic symbol table (no DT_SYMTAB entry)");
}
if (Dyn.SONameOffset.hasValue() && *Dyn.SONameOffset >= Dyn.StrSize) {
return createStringError(
object_error::parse_failed,
return createStringError(object_error::parse_failed,
"DT_SONAME string offset (0x%016" PRIx64
") outside of dynamic string table",
*Dyn.SONameOffset);
}
for (uint64_t Offset : Dyn.NeededLibNames) {
if (Offset >= Dyn.StrSize) {
return createStringError(
object_error::parse_failed,
return createStringError(object_error::parse_failed,
"DT_NEEDED string offset (0x%016" PRIx64
") outside of dynamic string table",
Offset);
@ -355,9 +353,8 @@ buildStub(const ELFObjectFile<ELFT> &ElfObj) {
if (!DynSymPtr)
return appendToError(DynSymPtr.takeError(),
"when locating .dynsym section contents");
Elf_Sym_Range DynSyms =
ArrayRef<Elf_Sym>(reinterpret_cast<const Elf_Sym *>(*DynSymPtr),
*SymCount);
Elf_Sym_Range DynSyms = ArrayRef<Elf_Sym>(
reinterpret_cast<const Elf_Sym *>(*DynSymPtr), *SymCount);
Error SymReadError = populateSymbols<ELFT>(*DestStub, DynSyms, DynStr);
if (SymReadError)
return appendToError(std::move(SymReadError),

View File

@ -6,7 +6,7 @@
//
//===-----------------------------------------------------------------------===/
#include "llvm/TextAPI/ELF/ELFStub.h"
#include "llvm/InterfaceStub/ELFStub.h"
using namespace llvm;
using namespace llvm::elfabi;

View File

@ -0,0 +1,21 @@
;===- ./lib/InterfaceStub/LLVMBuild.txt ------------------------*- Conf -*--===;
;
; Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
; See https://llvm.org/LICENSE.txt for license information.
; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
;
;===------------------------------------------------------------------------===;
;
; This is an LLVMBuild description file for the components in this subdirectory.
;
; For more information on the LLVMBuild system, please see:
;
; http://llvm.org/docs/LLVMBuild.html
;
;===------------------------------------------------------------------------===;
[component_0]
type = Library
name = InterfaceStub
parent = Libraries
required_libraries = Object Support

View File

@ -6,12 +6,12 @@
//
//===-----------------------------------------------------------------------===/
#include "llvm/TextAPI/ELF/TBEHandler.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/InterfaceStub/TBEHandler.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/InterfaceStub/ELFStub.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/YAMLTraits.h"
#include "llvm/TextAPI/ELF/ELFStub.h"
using namespace llvm;
using namespace llvm::elfabi;

View File

@ -30,6 +30,7 @@ subdirectories =
FuzzMutate
LineEditor
Linker
InterfaceStub
IR
IRReader
LTO

View File

@ -1,6 +1,4 @@
add_llvm_component_library(LLVMTextAPI
ELF/ELFStub.cpp
ELF/TBEHandler.cpp
MachO/Architecture.cpp
MachO/ArchitectureSet.cpp
MachO/InterfaceFile.cpp

View File

@ -1,11 +1,11 @@
set(LLVM_LINK_COMPONENTS
InterfaceStub
Object
Support
TextAPI
)
add_llvm_tool(llvm-elfabi
ELFObjHandler.cpp
ErrorCollector.cpp
llvm-elfabi.cpp
)

View File

@ -18,4 +18,4 @@
type = Tool
name = llvm-elfabi
parent = Tools
required_libraries = Object Support TextAPI
required_libraries = InterfaceStub Object Support TextAPI

View File

@ -6,16 +6,16 @@
//
//===-----------------------------------------------------------------------===/
#include "ELFObjHandler.h"
#include "ErrorCollector.h"
#include "llvm/InterfaceStub/ELFObjHandler.h"
#include "llvm/InterfaceStub/TBEHandler.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/FileOutputBuffer.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/WithColor.h"
#include "llvm/TextAPI/ELF/TBEHandler.h"
#include "llvm/Support/raw_ostream.h"
#include <string>
namespace llvm {

View File

@ -26,6 +26,7 @@ add_subdirectory(Demangle)
add_subdirectory(ExecutionEngine)
add_subdirectory(Frontend)
add_subdirectory(FuzzMutate)
add_subdirectory(InterfaceStub)
add_subdirectory(IR)
add_subdirectory(LineEditor)
add_subdirectory(Linker)

View File

@ -0,0 +1,9 @@
set(LLVM_LINK_COMPONENTS
InterfaceStub
)
add_llvm_unittest(InterfaceStubTests
ELFYAMLTest.cpp
)
target_link_libraries(InterfaceStubTests PRIVATE LLVMTestingSupport)

View File

@ -7,8 +7,8 @@
//===-----------------------------------------------------------------------===/
#include "llvm/ADT/StringRef.h"
#include "llvm/TextAPI/ELF/ELFStub.h"
#include "llvm/TextAPI/ELF/TBEHandler.h"
#include "llvm/InterfaceStub/ELFStub.h"
#include "llvm/InterfaceStub/TBEHandler.h"
#include "llvm/Support/Error.h"
#include "llvm/Testing/Support/Error.h"
#include "gtest/gtest.h"

View File

@ -3,7 +3,6 @@ set(LLVM_LINK_COMPONENTS
)
add_llvm_unittest(TextAPITests
ELFYAMLTest.cpp
TextStubV1Tests.cpp
TextStubV2Tests.cpp
TextStubV3Tests.cpp