forked from OSchip/llvm-project
parent
34ab70f1e6
commit
710b4c8fa2
|
@ -111,6 +111,16 @@ public:
|
|||
Segment(const ELFTargetInfo &ti, StringRef name,
|
||||
const Layout::SegmentType type);
|
||||
|
||||
enum SegmentOrder {
|
||||
permUnknown,
|
||||
permRWX,
|
||||
permRX,
|
||||
permR,
|
||||
permRWL,
|
||||
permRW,
|
||||
permNonAccess
|
||||
};
|
||||
|
||||
/// append a section to a segment
|
||||
void append(Section<ELFT> *section);
|
||||
|
||||
|
@ -166,12 +176,37 @@ public:
|
|||
|
||||
inline int pageSize() const { return this->_targetInfo.getPageSize(); }
|
||||
|
||||
inline int64_t atomflags() const { return _atomflags; }
|
||||
inline int rawflags() const { return _atomflags; }
|
||||
|
||||
inline int64_t numSlices() const {
|
||||
return _segmentSlices.size();
|
||||
inline int64_t atomflags() const {
|
||||
switch (_atomflags) {
|
||||
|
||||
case DefinedAtom::permUnknown:
|
||||
return permUnknown;
|
||||
|
||||
case DefinedAtom::permRWX:
|
||||
return permRWX;
|
||||
|
||||
case DefinedAtom::permR_X:
|
||||
return permRX;
|
||||
|
||||
case DefinedAtom::permR__:
|
||||
return permR;
|
||||
|
||||
case DefinedAtom::permRW_L:
|
||||
return permRWL;
|
||||
|
||||
case DefinedAtom::permRW_:
|
||||
return permRW;
|
||||
|
||||
case DefinedAtom::perm___:
|
||||
default:
|
||||
return permNonAccess;
|
||||
}
|
||||
}
|
||||
|
||||
inline int64_t numSlices() const { return _segmentSlices.size(); }
|
||||
|
||||
inline range<SliceIter> slices() { return _segmentSlices; }
|
||||
|
||||
// These two accessors are still needed for a call to std::stable_sort.
|
||||
|
@ -215,17 +250,12 @@ Segment<ELFT>::append(Section<ELFT> *section) {
|
|||
this->_align2 = section->align2();
|
||||
}
|
||||
|
||||
template<class ELFT>
|
||||
bool
|
||||
Segment<ELFT>::compareSegments(Segment<ELFT> *sega, Segment<ELFT> *segb) {
|
||||
if (sega->atomflags() < segb->atomflags())
|
||||
return false;
|
||||
return true;
|
||||
template <class ELFT>
|
||||
bool Segment<ELFT>::compareSegments(Segment<ELFT> *sega, Segment<ELFT> *segb) {
|
||||
return (sega->atomflags() < segb->atomflags());
|
||||
}
|
||||
|
||||
template<class ELFT>
|
||||
void
|
||||
Segment<ELFT>::assignOffsets(uint64_t startOffset) {
|
||||
template <class ELFT> void Segment<ELFT>::assignOffsets(uint64_t startOffset) {
|
||||
int startSection = 0;
|
||||
int currSection = 0;
|
||||
SectionIter startSectionIter, endSectionIter;
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
# RUN: llvm-nm -n %t1 | FileCheck %s
|
||||
#
|
||||
# CHECK: 000000a0 T main
|
||||
# CHECK: 00001000 A _end
|
||||
# CHECK: 00001000 A end
|
||||
# CHECK: 00002000 A _end
|
||||
# CHECK: 00002000 A end
|
||||
# CHECK: w _entrypoint
|
||||
|
||||
defined-atoms:
|
||||
|
|
|
@ -38,6 +38,6 @@ PLT: kind: R_X86_64_PC32
|
|||
|
||||
// This is a horribly brittle test. We need a way to do arithmetic on captured
|
||||
// variables.
|
||||
BIN: 40012c: ff 25 ce 0e 00 00 jmpq *3790(%rip)
|
||||
BIN: 40012c: ff 25 ce 1e 00 00 jmpq *7886(%rip)
|
||||
BIN: .got.plt:
|
||||
BIN-NEXT: 401000 00000000 00000000
|
||||
BIN-NEXT: 402000 00000000 00000000
|
||||
|
|
|
@ -3,7 +3,7 @@ RUN: lld-core -reader ELF -writer ELF -o %t1 %p/Inputs/phdr.i386 | elf-dump %t1
|
|||
RUN: lld -core -target x86_64-linux -output=%t1 %p/Inputs/relocs.x86-64 \
|
||||
RUN: && llvm-objdump -p %t1 | FileCheck %s -check-prefix=X86_64
|
||||
|
||||
ED: # Program Header 0
|
||||
|
||||
ED: (('p_type', 0x00000001)
|
||||
ED: ('p_flags', 0x00000005)
|
||||
ED: ('p_offset', 0x00000000)
|
||||
|
@ -15,15 +15,25 @@ ED: ('p_align', 0x00001000)
|
|||
ED: ),
|
||||
ED: # Program Header 1
|
||||
ED: (('p_type', 0x00000001)
|
||||
ED: ('p_flags', 0x00000006)
|
||||
ED: ('p_flags', 0x00000004)
|
||||
ED: ('p_offset', 0x00001000)
|
||||
ED: ('p_vaddr', 0x00001000)
|
||||
ED: ('p_paddr', 0x00001000)
|
||||
ED: ('p_filesz', 0x0000008c)
|
||||
ED: ('p_memsz', 0x0000008c)
|
||||
ED: ('p_align', 0x00001000)
|
||||
ED: ),
|
||||
ED: # Program Header 2
|
||||
ED: (('p_type', 0x00000001)
|
||||
ED: ('p_flags', 0x00000006)
|
||||
ED: ('p_offset', 0x00002000)
|
||||
ED: ('p_vaddr', 0x00002000)
|
||||
ED: ('p_paddr', 0x00002000)
|
||||
ED: ('p_filesz', 0x00000104)
|
||||
ED: ('p_memsz', 0x00000004)
|
||||
ED: ('p_align', 0x00001000)
|
||||
ED: ),
|
||||
ED: # Program Header 2
|
||||
ED: # Program Header 3
|
||||
ED: (('p_type', 0x00000001)
|
||||
ED: ('p_flags', 0x00000006)
|
||||
ED: ('p_offset', 0x00004000)
|
||||
|
@ -33,15 +43,5 @@ ED: ('p_filesz', 0x00000004)
|
|||
ED: ('p_memsz', 0x00004008)
|
||||
ED: ('p_align', 0x00001000)
|
||||
ED: ),
|
||||
ED: # Program Header 3
|
||||
ED: (('p_type', 0x00000001)
|
||||
ED: ('p_flags', 0x00000004)
|
||||
ED: ('p_offset', 0x00005000)
|
||||
ED: ('p_vaddr', 0x00009000)
|
||||
ED: ('p_paddr', 0x00009000)
|
||||
ED: ('p_filesz', 0x0000008c)
|
||||
ED: ('p_memsz', 0x0000008c)
|
||||
ED: ('p_align', 0x00001000)
|
||||
ED: ),
|
||||
|
||||
X86_64: vaddr 0x0000000000400000
|
||||
|
|
|
@ -19,9 +19,9 @@ RUN: llvm-nm -n %t1 | FileCheck -check-prefix CHECKSYMS %s
|
|||
|
||||
CHECKSYMS: 00000000 a 1.c
|
||||
CHECKSYMS: 00000094 T main
|
||||
CHECKSYMS: 00001000 A __bss_start
|
||||
CHECKSYMS: 00001000 B a
|
||||
CHECKSYMS: 00001004 A __bss_end
|
||||
CHECKSYMS: 00001004 A _end
|
||||
CHECKSYMS: 00001004 A end
|
||||
CHECKSYMS: 00002000 A __bss_start
|
||||
CHECKSYMS: 00002000 B a
|
||||
CHECKSYMS: 00002004 A __bss_end
|
||||
CHECKSYMS: 00002004 A _end
|
||||
CHECKSYMS: 00002004 A end
|
||||
CHECKSYMS: w _start
|
||||
|
|
Loading…
Reference in New Issue