/// Creates an error_code object that has associated with it an arbitrary
/// error messsage. The value() of the error_code will always be non-zero
-/// but its value is meaningless. The messsage() will be (a copy of) the
+/// but its value is meaningless. The messsage() will be (a copy of) the
/// supplied error string.
-/// Note: Once ErrorOr<> is updated to work with errors other than error_code,
+/// Note: Once ErrorOr<> is updated to work with errors other than error_code,
/// this can be updated to return some other kind of error.
std::error_code make_dynamic_error_code(StringRef msg);
std::error_code make_dynamic_error_code(const Twine &msg);
namespace lld {
/// Temporary class to enable make_dynamic_error_code() until
-/// llvm::ErrorOr<> is updated to work with error encapsulations
+/// llvm::ErrorOr<> is updated to work with error encapsulations
/// other than error_code.
class dynamic_error_category : public std::error_category {
public:
class ArchHandler {
public:
virtual ~ArchHandler();
-
+
/// There is no public interface to subclasses of ArchHandler, so this
/// is the only way to instantiate an ArchHandler.
static std::unique_ptr<ArchHandler> create(MachOLinkingContext::Arch arch);
/// Get (arch specific) kind strings used by Registry.
virtual const Registry::KindStrings *kindStrings() = 0;
-
- /// Convert mach-o Arch to Reference::KindArch.
+
+ /// Convert mach-o Arch to Reference::KindArch.
virtual Reference::KindArch kindArch() = 0;
/// Used by StubPass to update References to shared library functions
virtual const Atom *fdeTargetFunction(const DefinedAtom *fde);
- /// Used by normalizedFromAtoms() to know where to generated rebasing and
+ /// Used by normalizedFromAtoms() to know where to generated rebasing and
/// binding info in final executables.
virtual bool isPointer(const Reference &) = 0;
-
- /// Used by normalizedFromAtoms() to know where to generated lazy binding
+
+ /// Used by normalizedFromAtoms() to know where to generated lazy binding
/// info in final executables.
virtual bool isLazyPointer(const Reference &);
/// Returns true if the specified relocation is paired to the next relocation.
virtual bool isPairedReloc(const normalized::Relocation &) = 0;
- /// Prototype for a helper function. Given a sectionIndex and address,
- /// finds the atom and offset with that atom of that address.
- typedef std::function<std::error_code (uint32_t sectionIndex, uint64_t addr,
- const lld::Atom **, Reference::Addend *)>
+ /// Prototype for a helper function. Given a sectionIndex and address,
+ /// finds the atom and offset with that atom of that address.
+ typedef std::function<std::error_code (uint32_t sectionIndex, uint64_t addr,
+ const lld::Atom **, Reference::Addend *)>
FindAtomBySectionAndAddress;
-
+
/// Prototype for a helper function. Given a symbolIndex, finds the atom
/// representing that symbol.
- typedef std::function<std::error_code (uint32_t symbolIndex,
+ typedef std::function<std::error_code (uint32_t symbolIndex,
const lld::Atom **)> FindAtomBySymbolIndex;
/// Analyzes a relocation from a .o file and returns the info
/// (kind, target, addend) needed to instantiate a Reference.
/// Two helper functions are passed as parameters to find the target atom
/// given a symbol index or address.
- virtual std::error_code
+ virtual std::error_code
getReferenceInfo(const normalized::Relocation &reloc,
const DefinedAtom *inAtom,
uint32_t offsetInAtom,
uint64_t fixupAddress, bool isBigEndian,
FindAtomBySectionAndAddress atomFromAddress,
FindAtomBySymbolIndex atomFromSymbolIndex,
- Reference::KindValue *kind,
- const lld::Atom **target,
+ Reference::KindValue *kind,
+ const lld::Atom **target,
Reference::Addend *addend) = 0;
/// Analyzes a pair of relocations from a .o file and returns the info
/// (kind, target, addend) needed to instantiate a Reference.
/// Two helper functions are passed as parameters to find the target atom
/// given a symbol index or address.
- virtual std::error_code
+ virtual std::error_code
getPairReferenceInfo(const normalized::Relocation &reloc1,
const normalized::Relocation &reloc2,
const DefinedAtom *inAtom,
uint64_t fixupAddress, bool isBig, bool scatterable,
FindAtomBySectionAndAddress atomFromAddress,
FindAtomBySymbolIndex atomFromSymbolIndex,
- Reference::KindValue *kind,
- const lld::Atom **target,
+ Reference::KindValue *kind,
+ const lld::Atom **target,
Reference::Addend *addend) = 0;
/// Prototype for a helper function. Given an atom, finds the symbol table
ReferenceInfo lazyPointerReferenceToFinal;
ReferenceInfo nonLazyPointerReferenceToBinder;
uint8_t codeAlignment;
-
+
uint32_t stubSize;
uint8_t stubBytes[16];
ReferenceInfo stubReferenceToLP;
static uint16_t getWordFromThumbMov(uint32_t instruction);
static uint16_t getWordFromArmMov(uint32_t instruction);
static uint32_t clearThumbBit(uint32_t value, const Atom *target);
- static uint32_t setDisplacementInArmBranch(uint32_t instr, int32_t disp,
+ static uint32_t setDisplacementInArmBranch(uint32_t instr, int32_t disp,
bool targetIsThumb);
static uint32_t setDisplacementInThumbBranch(uint32_t instr, uint32_t ia,
int32_t disp, bool targetThumb);
static uint32_t setWordFromThumbMov(uint32_t instruction, uint16_t word);
static uint32_t setWordFromArmMov(uint32_t instruction, uint16_t word);
-
+
StringRef stubName(const DefinedAtom &);
bool useExternalRelocationTo(const Atom &target);
const ArchHandler::StubInfo ArchHandler_arm::_sStubInfoArmPIC = {
"dyld_stub_binder",
- // References in lazy pointer
+ // References in lazy pointer
{ Reference::KindArch::ARM, pointer32, 0, 0 },
{ Reference::KindArch::ARM, lazyPointer, 0, 0 },
-
+
// GOT pointer to dyld_stub_binder
{ Reference::KindArch::ARM, pointer32, 0, 0 },
// arm code alignment 2^2
- 2,
-
+ 2,
+
// Stub size and code
- 16,
+ 16,
{ 0x04, 0xC0, 0x9F, 0xE5, // ldr ip, pc + 12
0x0C, 0xC0, 0x8F, 0xE0, // add ip, pc, ip
0x00, 0xF0, 0x9C, 0xE5, // ldr pc, [ip]
0x00, 0x00, 0x00, 0x00 }, // .long L_foo$lazy_ptr - (L1$scv + 8)
{ Reference::KindArch::ARM, delta32, 12, 0 },
{ false, 0, 0, 0 },
-
+
// Stub Helper size and code
12,
{ 0x00, 0xC0, 0x9F, 0xE5, // ldr ip, [pc, #0]
0x00, 0x00, 0x00, 0x00 }, // .long lazy-info-offset
{ Reference::KindArch::ARM, lazyImmediateLocation, 8, 0 },
{ Reference::KindArch::ARM, arm_b24, 4, 0 },
-
+
// Stub Helper-Common size and code
36,
{ // push lazy-info-offset
lazyPointer, /// Location contains a lazy pointer.
lazyImmediateLocation, /// Location contains immediate value used in stub.
};
-
+
static bool useExternalRelocationTo(const Atom &target);
void applyFixupFinal(const Reference &ref, uint8_t *location,
//===----------------------------------------------------------------------===//
ArchHandler_x86::ArchHandler_x86() {}
-
+
ArchHandler_x86::~ArchHandler_x86() { }
-
+
const Registry::KindStrings ArchHandler_x86::_sKindStrings[] = {
LLD_KIND_STRING_ENTRY(invalid),
LLD_KIND_STRING_ENTRY(modeCode),
const ArchHandler::StubInfo ArchHandler_x86::_sStubInfo = {
"dyld_stub_binder",
- // Lazy pointer references
+ // Lazy pointer references
{ Reference::KindArch::x86, pointer32, 0, 0 },
{ Reference::KindArch::x86, lazyPointer, 0, 0 },
-
+
// GOT pointer to dyld_stub_binder
{ Reference::KindArch::x86, pointer32, 0, 0 },
// x86 code alignment
- 1,
-
+ 1,
+
// Stub size and code
- 6,
+ 6,
{ 0xff, 0x25, 0x00, 0x00, 0x00, 0x00 }, // jmp *lazyPointer
{ Reference::KindArch::x86, abs32, 2, 0 },
{ false, 0, 0, 0 },
-
+
// Stub Helper size and code
10,
{ 0x68, 0x00, 0x00, 0x00, 0x00, // pushl $lazy-info-offset
0xE9, 0x00, 0x00, 0x00, 0x00 }, // jmp helperhelper
{ Reference::KindArch::x86, lazyImmediateLocation, 1, 0 },
{ Reference::KindArch::x86, branch32, 6, 0 },
-
+
// Stub Helper-Common size and code
12,
{ 0x68, 0x00, 0x00, 0x00, 0x00, // pushl $dyld_ImageLoaderCache
if (ec)
return ec;
if (fromTarget != inAtom) {
- if (*target != inAtom)
+ if (*target != inAtom)
return make_dynamic_error_code(Twine("SECTDIFF relocation where "
"neither target is in atom"));
*kind = negDelta32;
uint64_t fixupAddress, bool swap,
FindAtomBySectionAndAddress atomFromAddress,
FindAtomBySymbolIndex atomFromSymbolIndex,
- Reference::KindValue *kind,
- const lld::Atom **target,
+ Reference::KindValue *kind,
+ const lld::Atom **target,
Reference::Addend *addend) override;
- std::error_code
+ std::error_code
getPairReferenceInfo(const normalized::Relocation &reloc1,
const normalized::Relocation &reloc2,
const DefinedAtom *inAtom,
uint64_t fixupAddress, bool swap, bool scatterable,
FindAtomBySectionAndAddress atomFromAddress,
FindAtomBySymbolIndex atomFromSymbolIndex,
- Reference::KindValue *kind,
- const lld::Atom **target,
+ Reference::KindValue *kind,
+ const lld::Atom **target,
Reference::Addend *addend) override;
bool needsLocalSymbolInRelocatableFile(const DefinedAtom *atom) override {
enum X86_64Kind: Reference::KindValue {
invalid, /// for error condition
-
+
// Kinds found in mach-o .o files:
branch32, /// ex: call _foo
ripRel32, /// ex: movq _foo(%rip), %rax
negDelta32, /// ex: .long . - _foo
// Kinds introduced by Passes:
- ripRel32GotLoadNowLea, /// Target of GOT load is in linkage unit so
+ ripRel32GotLoadNowLea, /// Target of GOT load is in linkage unit so
/// "movq _foo@GOTPCREL(%rip), %rax" can be changed
/// to "leaq _foo(%rip), %rax
lazyPointer, /// Location contains a lazy pointer.
const ArchHandler::StubInfo ArchHandler_x86_64::_sStubInfo = {
"dyld_stub_binder",
- // Lazy pointer references
+ // Lazy pointer references
{ Reference::KindArch::x86_64, pointer64, 0, 0 },
{ Reference::KindArch::x86_64, lazyPointer, 0, 0 },
-
+
// GOT pointer to dyld_stub_binder
{ Reference::KindArch::x86_64, pointer64, 0, 0 },
// x86_64 code alignment 2^1
- 1,
-
+ 1,
+
// Stub size and code
- 6,
+ 6,
{ 0xff, 0x25, 0x00, 0x00, 0x00, 0x00 }, // jmp *lazyPointer
{ Reference::KindArch::x86_64, ripRel32, 2, 0 },
{ false, 0, 0, 0 },
-
+
// Stub Helper size and code
10,
{ 0x68, 0x00, 0x00, 0x00, 0x00, // pushq $lazy-info-offset
0xE9, 0x00, 0x00, 0x00, 0x00 }, // jmp helperhelper
{ Reference::KindArch::x86_64, lazyImmediateLocation, 1, 0 },
{ Reference::KindArch::x86_64, branch32, 6, 0 },
-
+
// Stub Helper-Common size and code
16,
{ 0x4C, 0x8D, 0x1D, 0x00, 0x00, 0x00, 0x00, // leaq cache(%rip),%r11
{ false, 0, 0, 0 },
{ Reference::KindArch::x86_64, ripRel32, 11, 0 },
{ false, 0, 0, 0 }
-
+
};
bool ArchHandler_x86_64::isCallSite(const Reference &ref) {
}
}
-std::error_code
+std::error_code
ArchHandler_x86_64::getReferenceInfo(const Relocation &reloc,
const DefinedAtom *inAtom,
uint32_t offsetInAtom,
uint64_t fixupAddress, bool swap,
FindAtomBySectionAndAddress atomFromAddress,
FindAtomBySymbolIndex atomFromSymbolIndex,
- Reference::KindValue *kind,
- const lld::Atom **target,
+ Reference::KindValue *kind,
+ const lld::Atom **target,
Reference::Addend *addend) {
typedef std::error_code E;
*kind = kindFromReloc(reloc);
bool scatterable,
FindAtomBySectionAndAddress atomFromAddress,
FindAtomBySymbolIndex atomFromSymbolIndex,
- Reference::KindValue *kind,
- const lld::Atom **target,
+ Reference::KindValue *kind,
+ const lld::Atom **target,
Reference::Addend *addend) {
*kind = kindFromRelocPair(reloc1, reloc2);
if (*kind == invalid)
addAtom(*atom);
_undefAtoms[name] = atom;
}
-
+
/// Search this file for an the atom from 'section' that covers
/// 'offsetInSect'. Returns nullptr is no atom found.
MachODefinedAtom *findAtomCoveringAddress(const Section §ion,
assert(offsetInSect < section.content.size());
// Vector of atoms for section are already sorted, so do binary search.
const auto &atomPos = std::lower_bound(vec.begin(), vec.end(), offsetInSect,
- [offsetInSect](const SectionOffsetAndAtom &ao,
+ [offsetInSect](const SectionOffsetAndAtom &ao,
uint64_t targetAddr) -> bool {
// Each atom has a start offset of its slice of the
// section's content. This compare function must return true
return nullptr;
return pos->second;
}
-
+
typedef std::function<void (MachODefinedAtom* atom)> DefinedAtomVisitor;
void eachDefinedAtom(DefinedAtomVisitor vistor) {
return ec;
return std::error_code();
}
-
+
private:
struct SectionOffsetAndAtom { uint64_t offset; MachODefinedAtom *atom; };
- void addAtomForSection(const Section *inSection, MachODefinedAtom* atom,
+ void addAtomForSection(const Section *inSection, MachODefinedAtom* atom,
uint64_t sectionOffset) {
SectionOffsetAndAtom offAndAtom;
offAndAtom.offset = sectionOffset;
addAtom(*atom);
}
-
- typedef llvm::DenseMap<const normalized::Section *,
+
+ typedef llvm::DenseMap<const normalized::Section *,
std::vector<SectionOffsetAndAtom>> SectionToAtoms;
typedef llvm::StringMap<const lld::Atom *> NameToAtom;
/// Pass for instantiating and optimizing GOT slots.
-///
+///
class GOTPass : public Pass {
public:
GOTPass(const MachOLinkingContext &context)
: _context(context), _archHandler(_context.archHandler()),
- _file("<mach-o GOT Pass>") { }
+ _file("<mach-o GOT Pass>") { }
private:
// by-passed, do that optimization and don't create GOT entry.
return !canBypassGOT;
}
-
+
const DefinedAtom *makeGOTEntry(const Atom *target) {
auto pos = _targetToGOT.find(target);
if (pos == _targetToGOT.end()) {
- GOTEntryAtom *gotEntry = new (_file.allocator())
+ GOTEntryAtom *gotEntry = new (_file.allocator())
GOTEntryAtom(_file, _context.is64Bit(), target->name());
_targetToGOT[target] = gotEntry;
const ArchHandler::ReferenceInfo &nlInfo = _archHandler.stubInfo().
return pos->second;
}
-
+
const MachOLinkingContext &_context;
mach_o::ArchHandler &_archHandler;
MachOFile _file;
assert(ctx.needsGOTPass());
pm.add(llvm::make_unique<GOTPass>(ctx));
}
-
+
} // end namesapce mach_o
} // end namesapce lld
MachOLinkingContext::Arch arch = ctx.arch();
add(std::unique_ptr<Reader>(new mach_o::normalized::MachOObjectReader(ctx)));
add(std::unique_ptr<Reader>(new mach_o::normalized::MachODylibReader(ctx)));
- addKindTable(Reference::KindNamespace::mach_o, ctx.archHandler().kindArch(),
+ addKindTable(Reference::KindNamespace::mach_o, ctx.archHandler().kindArch(),
ctx.archHandler().kindStrings());
add(std::unique_ptr<YamlIOTaggedDocumentHandler>(
new mach_o::MachOYamlIOTaggedDocumentHandler(arch)));
}
}
// Otherwise allocate new SectionInfo object.
- SectionInfo *sect = new (_allocator) SectionInfo(segmentName, sectionName,
+ SectionInfo *sect = new (_allocator) SectionInfo(segmentName, sectionName,
sectionType, _context,
sectionAttrs);
_sectionInfos.push_back(sect);
{DefinedAtom::type, size, DefinedAtom::scope, DefinedAtom::merge, model }
static const ParseInfo parseInfo[] = {
- ENTRY(typeCode, 1, scopeGlobal, mergeNo,
+ ENTRY(typeCode, 1, scopeGlobal, mergeNo,
atomizeAtSymbols),
- ENTRY(typeData, 1, scopeGlobal, mergeNo,
+ ENTRY(typeData, 1, scopeGlobal, mergeNo,
atomizeAtSymbols),
- ENTRY(typeConstData, 1, scopeGlobal, mergeNo,
+ ENTRY(typeConstData, 1, scopeGlobal, mergeNo,
atomizeAtSymbols),
- ENTRY(typeZeroFill, 1, scopeGlobal, mergeNo,
+ ENTRY(typeZeroFill, 1, scopeGlobal, mergeNo,
atomizeAtSymbols),
- ENTRY(typeConstant, 1, scopeGlobal, mergeNo,
+ ENTRY(typeConstant, 1, scopeGlobal, mergeNo,
atomizeAtSymbols),
- ENTRY(typeCString, 1, scopeLinkageUnit, mergeByContent,
+ ENTRY(typeCString, 1, scopeLinkageUnit, mergeByContent,
atomizeUTF8),
- ENTRY(typeUTF16String, 1, scopeLinkageUnit, mergeByContent,
+ ENTRY(typeUTF16String, 1, scopeLinkageUnit, mergeByContent,
atomizeUTF16),
ENTRY(typeCFI, 4, scopeTranslationUnit, mergeNo,
atomizeCFI),
- ENTRY(typeLiteral4, 4, scopeLinkageUnit, mergeByContent,
+ ENTRY(typeLiteral4, 4, scopeLinkageUnit, mergeByContent,
atomizeFixedSize),
- ENTRY(typeLiteral8, 8, scopeLinkageUnit, mergeByContent,
+ ENTRY(typeLiteral8, 8, scopeLinkageUnit, mergeByContent,
atomizeFixedSize),
- ENTRY(typeLiteral16, 16, scopeLinkageUnit, mergeByContent,
+ ENTRY(typeLiteral16, 16, scopeLinkageUnit, mergeByContent,
atomizeFixedSize),
- ENTRY(typeCFString, 4, scopeLinkageUnit, mergeByContent,
+ ENTRY(typeCFString, 4, scopeLinkageUnit, mergeByContent,
atomizeCFString),
- ENTRY(typeInitializerPtr, 4, scopeTranslationUnit, mergeNo,
+ ENTRY(typeInitializerPtr, 4, scopeTranslationUnit, mergeNo,
atomizePointerSize),
- ENTRY(typeTerminatorPtr, 4, scopeTranslationUnit, mergeNo,
+ ENTRY(typeTerminatorPtr, 4, scopeTranslationUnit, mergeNo,
atomizePointerSize),
- ENTRY(typeCompactUnwindInfo, 4, scopeTranslationUnit, mergeNo,
+ ENTRY(typeCompactUnwindInfo, 4, scopeTranslationUnit, mergeNo,
atomizeCU),
- ENTRY(typeGOT, 4, scopeLinkageUnit, mergeByContent,
+ ENTRY(typeGOT, 4, scopeLinkageUnit, mergeByContent,
atomizePointerSize),
- ENTRY(typeUnknown, 1, scopeGlobal, mergeNo,
+ ENTRY(typeUnknown, 1, scopeGlobal, mergeNo,
atomizeAtSymbols)
};
#undef ENTRY
// Debug logging of symbols.
//for (const Symbol *sym : symbols)
- // llvm::errs() << " sym: "
- // << llvm::format("0x%08llx ", (uint64_t)sym->value)
+ // llvm::errs() << " sym: "
+ // << llvm::format("0x%08llx ", (uint64_t)sym->value)
// << ", " << sym->name << "\n";
// If section has no symbols and no content, there are no atoms.
+ ")" );
} else {
// Instantiate an lld::Reference object and add to its atom.
- inAtom->addReference(offsetInAtom, kind, target, addend,
+ inAtom->addReference(offsetInAtom, kind, target, addend,
handler.kindArch());
}
}
//
class LazyPointerAtom : public SimpleDefinedAtom {
public:
- LazyPointerAtom(const File &file, bool is64)
+ LazyPointerAtom(const File &file, bool is64)
: SimpleDefinedAtom(file), _is64(is64) { }
ContentType contentType() const override {
//
class NonLazyPointerAtom : public SimpleDefinedAtom {
public:
- NonLazyPointerAtom(const File &file, bool is64)
+ NonLazyPointerAtom(const File &file, bool is64)
: SimpleDefinedAtom(file), _is64(is64) { }
ContentType contentType() const override {
}
ArrayRef<uint8_t> rawContent() const override {
- return llvm::makeArrayRef(_stubInfo.stubHelperBytes,
+ return llvm::makeArrayRef(_stubInfo.stubHelperBytes,
_stubInfo.stubHelperSize);
}
}
ArrayRef<uint8_t> rawContent() const override {
- return llvm::makeArrayRef(_stubInfo.stubHelperCommonBytes,
+ return llvm::makeArrayRef(_stubInfo.stubHelperCommonBytes,
_stubInfo.stubHelperCommonSize);
}
// Skip this pass if output format uses text relocations instead of stubs.
if (!this->noTextRelocs())
return;
-
+
// Scan all references in all atoms.
for (const DefinedAtom *atom : mergedFile->defined()) {
for (const Reference *ref : *atom) {
bool isCallSite(const Reference &ref) {
return _archHandler.isCallSite(ref);
}
-
+
void addReference(SimpleDefinedAtom* atom,
const ArchHandler::ReferenceInfo &refInfo,
const lld::Atom* target) {
CHECK: r_paren: )
CHECK: r_brace: }
CHECK: r_brace: }
-CHECK: eof:
+CHECK: eof:
CHECK: SEARCH_DIR("/usr/x86_64-linux-gnu/lib64")
CHECK: SEARCH_DIR("=/usr/local/lib/x86_64-linux-gnu")
CHECK: SECTIONS
CHECK: PROVIDE(__executable_start = SEGMENT_START(text-segment, 4194304))
CHECK: . = (SEGMENT_START(text-segment, 4194304) + SIZEOF_HEADERS)
CHECK: .interp :
-CHECK: {
+CHECK: {
CHECK: *(.interp)
CHECK: }
CHECK: .note.gnu.build-id :
-CHECK: {
+CHECK: {
CHECK: *(.note.gnu.build-id)
CHECK: }
CHECK: .hash :
-CHECK: {
+CHECK: {
CHECK: *(.hash)
CHECK: }
CHECK: .rela.dyn :
-CHECK: {
+CHECK: {
CHECK: *(.rela.init)
CHECK: *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
CHECK: *(.rela.fini)
CHECK: *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
CHECK: }
CHECK: .rela.plt :
-CHECK: {
+CHECK: {
CHECK: *(.rela.plt)
CHECK: PROVIDE_HIDDEN(__rela_iplt_start = .)
CHECK: *(.rela.iplt)
CHECK: PROVIDE_HIDDEN(__rela_iplt_end = .)
CHECK: }
CHECK: .init :
-CHECK: {
+CHECK: {
CHECK: KEEP(*(SORT_NONE(.init)))
CHECK: } =0x909090909090909090909090
CHECK: PROVIDE(__etext = .)
CHECK: .eh_frame :
-CHECK: ONLY_IF_RO {
+CHECK: ONLY_IF_RO {
CHECK: KEEP(*(.eh_frame))
CHECK: }
CHECK: .exception_ranges :
-CHECK: ONLY_IF_RO {
+CHECK: ONLY_IF_RO {
CHECK: *(.exception_ranges .exception_ranges*)
CHECK: }
CHECK: . = (ALIGN(CONSTANT(MAXPAGESIZE)) - ((CONSTANT(MAXPAGESIZE) - .) & (CONSTANT(MAXPAGESIZE) - 1)))
CHECK: . = DATA_SEGMENT_ALIGN(CONSTANT(MAXPAGESIZE), CONSTANT(COMMONPAGESIZE))
CHECK: .eh_frame :
-CHECK: ONLY_IF_RW {
+CHECK: ONLY_IF_RW {
CHECK: KEEP(*(.eh_frame))
CHECK: }
CHECK: .ctors :
-CHECK: {
+CHECK: {
CHECK: KEEP(*crtbegin.o(.ctors))
CHECK: KEEP(*crtbegin?.o(.ctors))
CHECK: KEEP(*(EXCLUDE_FILE(*crtend.o *crtend?.o ) .ctors))
CHECK: KEEP(*(.ctors))
CHECK: }
CHECK: .dtors :
-CHECK: {
+CHECK: {
CHECK: KEEP(*crtbegin.o(.dtors))
CHECK: KEEP(*crtbegin?.o(.dtors))
CHECK: KEEP(*(EXCLUDE_FILE(*crtend.o *crtend?.o ) .dtors))
CHECK: }
CHECK: . = DATA_SEGMENT_RELRO_END((SIZEOF(.got.plt) >= 24) ? 24 : 0, .)
CHECK: .got.plt :
-CHECK: {
+CHECK: {
CHECK: *(.got.plt)
CHECK: *(.igot.plt)
CHECK: }
CHECK: .lrodata (ALIGN(CONSTANT(MAXPAGESIZE)) + (. & (CONSTANT(MAXPAGESIZE) - 1))) :
-CHECK: {
+CHECK: {
CHECK: *(.lrodata .lrodata.* .gnu.linkonce.lr.*)
CHECK: }
CHECK: .ldata (ALIGN(CONSTANT(MAXPAGESIZE)) + (. & (CONSTANT(MAXPAGESIZE) - 1))) :
-CHECK: {
+CHECK: {
CHECK: *(.ldata .ldata.* .gnu.linkonce.l.*)
CHECK: . = ALIGN((. != 0) ? (64 / 8) : 1)
CHECK: }
CHECK: PROVIDE(end = .)
CHECK: . = DATA_SEGMENT_END(.)
CHECK: :
-CHECK: {
+CHECK: {
CHECK: *(.note.GNU-stack)
CHECK: *(.gnu_debuglink)
CHECK: *(.gnu.lto_*)
# CHECK-NEXT: 0x00000014 PLTREL REL
# CHECK-NEXT: 0x00000017 JMPREL 0x400154
# CHECK-NEXT: 0x70000001 MIPS_RLD_VERSION 1
-# CHECK-NEXT: 0x70000005 MIPS_FLAGS NOTPOT
+# CHECK-NEXT: 0x70000005 MIPS_FLAGS NOTPOT
# CHECK-NEXT: 0x70000006 MIPS_BASE_ADDRESS 0x400000
# CHECK-NEXT: 0x7000000A MIPS_LOCAL_GOTNO 2
# CHECK-NEXT: 0x70000011 MIPS_SYMTABNO 2
# SEC: Contents of section .text:
# SEC-NEXT: 400190 41000000 f08f0000 60001000
# SEC: Contents of section .got:
-# SEC-NEXT: 401000 00000000 00000080
+# SEC-NEXT: 401000 00000000 00000080
# so.o
---
# so1.o
---
-FileHeader:
+FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
OSABI: ELFOSABI_GNU
Machine: EM_MIPS
Flags: [ EF_MIPS_NOREORDER, EF_MIPS_PIC, EF_MIPS_CPIC,
EF_MIPS_ABI_O32, EF_MIPS_ARCH_32R2 ]
-Sections:
+Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Link: .symtab
AddressAlign: 0x04
Info: .text
- Relocations:
+ Relocations:
- Offset: 0x00
Symbol: L01
Type: R_MIPS_TLS_LDM
AddressAlign: 0x04
Size: 0x04
-Symbols:
- Local:
+Symbols:
+ Local:
- Name: L01
Type: STT_TLS
Section: .tdata
Size: 0x04
- Global:
+ Global:
- Name: T1
Type: STT_FUNC
Section: .text
# so2.o
---
-FileHeader:
+FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
OSABI: ELFOSABI_GNU
Machine: EM_MIPS
Flags: [ EF_MIPS_NOREORDER, EF_MIPS_PIC, EF_MIPS_CPIC,
EF_MIPS_ABI_O32, EF_MIPS_ARCH_32R2 ]
-Sections:
+Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Link: .symtab
AddressAlign: 0x04
Info: .text
- Relocations:
+ Relocations:
- Offset: 0x00
Symbol: L02
Type: R_MIPS_TLS_LDM
AddressAlign: 0x04
Size: 0x04
-Symbols:
- Local:
+Symbols:
+ Local:
- Name: L02
Type: STT_TLS
Section: .tdata
Size: 0x04
- Global:
+ Global:
- Name: T3
Type: STT_FUNC
Section: .text
#CHECKLAYOUT-NEXT: AddressAlign:
#CHECKLAYOUT-NEXT: Content: 554889E5E8020000005DC3554889E5B8640000005DC3
# ^~~> my_func ^~~> my_weak_func
-#
+#
#
#
#Our two input files were produced by the following code:
# retq
# .Ltmp0:
# .size my_func, .Ltmp0-my_func
-#
+#
# .text
# .weak my_weak_func
# .type my_weak_func,@function
# .Ltmp1:
# .size my_weak_func, .Ltmp1-my_weak_func
# .size my_weak_func2, .Ltmp1-my_weak_func2
-# .size my_weak_func3, .Ltmp1-my_weak_func3
-#
+# .size my_weak_func3, .Ltmp1-my_weak_func3
+#
#Inputs/main-with-global-def.o.yaml:
#
# int my_func();
-#
+#
# int my_weak_func2() {
# return 200;
# }
-#
+#
# int main() {
# return my_func();
# }
# return mysecretfunc() + mysecretvar;
# }
---
-FileHeader:
+FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
OSABI: ELFOSABI_GNU
Type: ET_REL
Machine: EM_X86_64
-Sections:
+Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Link: .symtab
AddressAlign: 0x0000000000000008
Info: .text
- Relocations:
+ Relocations:
- Offset: 0x0000000000000027
Symbol: .data
Type: R_X86_64_32S
Flags: [ SHF_WRITE, SHF_ALLOC ]
AddressAlign: 0x0000000000000004
Content: ''
-Symbols:
- Local:
+Symbols:
+ Local:
- Name: mysecretfunc
Type: STT_FUNC
Section: .text
- Name: .bss
Type: STT_SECTION
Section: .bss
- Global:
+ Global:
- Name: main
Type: STT_FUNC
Section: .text