LLVM 19.0.0git
Typedefs | Functions
ELFObjcopy.cpp File Reference
#include "llvm/ObjCopy/ELF/ELFObjcopy.h"
#include "ELFObject.h"
#include "llvm/ADT/BitmaskEnum.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/BinaryFormat/ELF.h"
#include "llvm/MC/MCTargetOptions.h"
#include "llvm/ObjCopy/CommonConfig.h"
#include "llvm/ObjCopy/ELF/ELFConfig.h"
#include "llvm/Object/Binary.h"
#include "llvm/Object/ELFObjectFile.h"
#include "llvm/Object/ELFTypes.h"
#include "llvm/Object/Error.h"
#include "llvm/Option/Option.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Compression.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Memory.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
#include <cstdlib>
#include <functional>
#include <iterator>
#include <memory>
#include <string>
#include <system_error>
#include <utility>

Go to the source code of this file.

Typedefs

using SectionPred = std::function< bool(const SectionBase &Sec)>
 

Functions

static bool isDebugSection (const SectionBase &Sec)
 
static bool isDWOSection (const SectionBase &Sec)
 
static bool onlyKeepDWOPred (const Object &Obj, const SectionBase &Sec)
 
static Expected< uint64_tgetNewShfFlags (SectionFlag AllFlags, uint16_t EMachine)
 
static uint64_t getSectionFlagsPreserveMask (uint64_t OldFlags, uint64_t NewFlags, uint16_t EMachine)
 
static void setSectionType (SectionBase &Sec, uint64_t Type)
 
static Error setSectionFlagsAndType (SectionBase &Sec, SectionFlag Flags, uint16_t EMachine)
 
static ElfType getOutputElfType (const Binary &Bin)
 
static ElfType getOutputElfType (const MachineInfo &MI)
 
static std::unique_ptr< WritercreateELFWriter (const CommonConfig &Config, Object &Obj, raw_ostream &Out, ElfType OutputElfType)
 
static std::unique_ptr< WritercreateWriter (const CommonConfig &Config, Object &Obj, raw_ostream &Out, ElfType OutputElfType)
 
static Error dumpSectionToFile (StringRef SecName, StringRef Filename, Object &Obj)
 
static bool isAArch64MappingSymbol (const Symbol &Sym)
 
static bool isArmMappingSymbol (const Symbol &Sym)
 
static bool isRequiredByABISymbol (const Object &Obj, const Symbol &Sym)
 
static bool isUnneededSymbol (const Symbol &Sym)
 
static Error updateAndRemoveSymbols (const CommonConfig &Config, const ELFConfig &ELFConfig, Object &Obj)
 
static Error replaceAndRemoveSections (const CommonConfig &Config, const ELFConfig &ELFConfig, Object &Obj)
 
static void addSymbol (Object &Obj, const NewSymbolInfo &SymInfo, uint8_t DefaultVisibility)
 
static Error handleUserSection (const NewSectionInfo &NewSection, function_ref< Error(StringRef, ArrayRef< uint8_t >)> F)
 
static Error handleArgs (const CommonConfig &Config, const ELFConfig &ELFConfig, Object &Obj)
 
static Error writeOutput (const CommonConfig &Config, Object &Obj, raw_ostream &Out, ElfType OutputElfType)
 

Typedef Documentation

◆ SectionPred

Definition at line 52 of file ELFObjcopy.cpp.

Function Documentation

◆ addSymbol()

static void addSymbol ( Object Obj,
const NewSymbolInfo SymInfo,
uint8_t  DefaultVisibility 
)
static

◆ createELFWriter()

static std::unique_ptr< Writer > createELFWriter ( const CommonConfig Config,
Object Obj,
raw_ostream Out,
ElfType  OutputElfType 
)
static

◆ createWriter()

static std::unique_ptr< Writer > createWriter ( const CommonConfig Config,
Object Obj,
raw_ostream Out,
ElfType  OutputElfType 
)
static

Definition at line 178 of file ELFObjcopy.cpp.

References Config, and createELFWriter().

Referenced by writeOutput().

◆ dumpSectionToFile()

static Error dumpSectionToFile ( StringRef  SecName,
StringRef  Filename,
Object Obj 
)
static

◆ getNewShfFlags()

static Expected< uint64_t > getNewShfFlags ( SectionFlag  AllFlags,
uint16_t  EMachine 
)
static

◆ getOutputElfType() [1/2]

static ElfType getOutputElfType ( const Binary Bin)
static

◆ getOutputElfType() [2/2]

static ElfType getOutputElfType ( const MachineInfo MI)
static

◆ getSectionFlagsPreserveMask()

static uint64_t getSectionFlagsPreserveMask ( uint64_t  OldFlags,
uint64_t  NewFlags,
uint16_t  EMachine 
)
static

◆ handleArgs()

static Error handleArgs ( const CommonConfig Config,
const ELFConfig ELFConfig,
Object Obj 
)
static

◆ handleUserSection()

static Error handleUserSection ( const NewSectionInfo NewSection,
function_ref< Error(StringRef, ArrayRef< uint8_t >)>  F 
)
static

◆ isAArch64MappingSymbol()

static bool isAArch64MappingSymbol ( const Symbol &  Sym)
static

◆ isArmMappingSymbol()

static bool isArmMappingSymbol ( const Symbol &  Sym)
static

◆ isDebugSection()

static bool isDebugSection ( const SectionBase Sec)
static

◆ isDWOSection()

static bool isDWOSection ( const SectionBase Sec)
static

◆ isRequiredByABISymbol()

static bool isRequiredByABISymbol ( const Object Obj,
const Symbol &  Sym 
)
static

◆ isUnneededSymbol()

static bool isUnneededSymbol ( const Symbol &  Sym)
static

◆ onlyKeepDWOPred()

static bool onlyKeepDWOPred ( const Object Obj,
const SectionBase Sec 
)
static

Definition at line 62 of file ELFObjcopy.cpp.

References isDWOSection(), and llvm::objcopy::elf::Object::SectionNames.

Referenced by replaceAndRemoveSections().

◆ replaceAndRemoveSections()

static Error replaceAndRemoveSections ( const CommonConfig Config,
const ELFConfig ELFConfig,
Object Obj 
)
static

◆ setSectionFlagsAndType()

static Error setSectionFlagsAndType ( SectionBase Sec,
SectionFlag  Flags,
uint16_t  EMachine 
)
static

◆ setSectionType()

static void setSectionType ( SectionBase Sec,
uint64_t  Type 
)
static

◆ updateAndRemoveSymbols()

static Error updateAndRemoveSymbols ( const CommonConfig Config,
const ELFConfig ELFConfig,
Object Obj 
)
static

◆ writeOutput()

static Error writeOutput ( const CommonConfig Config,
Object Obj,
raw_ostream Out,
ElfType  OutputElfType 
)
static