Skip to content

Commit 4563918

Browse files
committed
merge main into amd-staging
2 parents 9727781 + 5d03e7a commit 4563918

File tree

163 files changed

+5697
-1329
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

163 files changed

+5697
-1329
lines changed

.github/workflows/libclang-python-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ on:
1010
- 'main'
1111
paths:
1212
- 'clang/bindings/python/**'
13-
- 'clang/test/bindings/python/**'
1413
- 'clang/tools/libclang/**'
14+
- 'clang/CMakeList.txt'
1515
- '.github/workflows/libclang-python-tests.yml'
1616
- '.github/workflows/llvm-project-tests.yml'
1717
pull_request:
1818
paths:
1919
- 'clang/bindings/python/**'
20-
- 'clang/test/bindings/python/**'
2120
- 'clang/tools/libclang/**'
21+
- 'clang/CMakeList.txt'
2222
- '.github/workflows/libclang-python-tests.yml'
2323
- '.github/workflows/llvm-project-tests.yml'
2424

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,9 @@ Error RewriteInstance::discoverStorage() {
626626
NextAvailableAddress += BC->PageAlign;
627627
}
628628

629+
NewTextSegmentAddress = NextAvailableAddress;
630+
NewTextSegmentOffset = NextAvailableOffset;
631+
629632
if (!opts::UseGnuStack && !BC->IsLinuxKernel) {
630633
// This is where the black magic happens. Creating PHDR table in a segment
631634
// other than that containing ELF header is tricky. Some loaders and/or
@@ -652,6 +655,8 @@ Error RewriteInstance::discoverStorage() {
652655

653656
PHDRTableAddress = NextAvailableAddress;
654657
PHDRTableOffset = NextAvailableOffset;
658+
NewTextSegmentAddress = NextAvailableAddress;
659+
NewTextSegmentOffset = NextAvailableOffset;
655660

656661
// Reserve space for 3 extra pheaders.
657662
unsigned Phnum = Obj.getHeader().e_phnum;
@@ -664,14 +669,12 @@ Error RewriteInstance::discoverStorage() {
664669

665670
NextAvailableAddress += Phnum * sizeof(ELF64LEPhdrTy);
666671
NextAvailableOffset += Phnum * sizeof(ELF64LEPhdrTy);
667-
}
668672

669-
// Align at cache line.
670-
NextAvailableAddress = alignTo(NextAvailableAddress, 64);
671-
NextAvailableOffset = alignTo(NextAvailableOffset, 64);
673+
// Align at cache line.
674+
NextAvailableAddress = alignTo(NextAvailableAddress, 64);
675+
NextAvailableOffset = alignTo(NextAvailableOffset, 64);
676+
}
672677

673-
NewTextSegmentAddress = NextAvailableAddress;
674-
NewTextSegmentOffset = NextAvailableOffset;
675678
BC->LayoutStartAddress = NextAvailableAddress;
676679

677680
// Tools such as objcopy can strip section contents but leave header
@@ -4133,13 +4136,8 @@ void RewriteInstance::mapAllocatableSections(
41334136
}
41344137

41354138
if (SType == ST_READONLY) {
4136-
if (PHDRTableAddress) {
4137-
// Segment size includes the size of the PHDR area.
4138-
NewTextSegmentSize = NextAvailableAddress - PHDRTableAddress;
4139-
} else if (NewTextSegmentAddress) {
4140-
// Existing PHDR table would be updated.
4139+
if (NewTextSegmentAddress)
41414140
NewTextSegmentSize = NextAvailableAddress - NewTextSegmentAddress;
4142-
}
41434141
} else if (SType == ST_READWRITE) {
41444142
NewWritableSegmentSize = NextAvailableAddress - NewWritableSegmentAddress;
41454143
// Restore NextAvailableAddress if no new writable sections
@@ -4186,9 +4184,7 @@ void RewriteInstance::patchELFPHDRTable() {
41864184
// NOTE Currently .eh_frame_hdr appends to the last segment, recalculate
41874185
// last segments size based on the NextAvailableAddress variable.
41884186
if (!NewWritableSegmentSize) {
4189-
if (PHDRTableAddress)
4190-
NewTextSegmentSize = NextAvailableAddress - PHDRTableAddress;
4191-
else if (NewTextSegmentAddress)
4187+
if (NewTextSegmentAddress)
41924188
NewTextSegmentSize = NextAvailableAddress - NewTextSegmentAddress;
41934189
} else {
41944190
NewWritableSegmentSize = NextAvailableAddress - NewWritableSegmentAddress;
@@ -4201,15 +4197,9 @@ void RewriteInstance::patchELFPHDRTable() {
42014197
SmallVector<ELF64LEPhdrTy, 3> NewPhdrs;
42024198
ELF64LEPhdrTy NewPhdr;
42034199
NewPhdr.p_type = ELF::PT_LOAD;
4204-
if (PHDRTableAddress) {
4205-
NewPhdr.p_offset = PHDRTableOffset;
4206-
NewPhdr.p_vaddr = PHDRTableAddress;
4207-
NewPhdr.p_paddr = PHDRTableAddress;
4208-
} else {
4209-
NewPhdr.p_offset = NewTextSegmentOffset;
4210-
NewPhdr.p_vaddr = NewTextSegmentAddress;
4211-
NewPhdr.p_paddr = NewTextSegmentAddress;
4212-
}
4200+
NewPhdr.p_offset = NewTextSegmentOffset;
4201+
NewPhdr.p_vaddr = NewTextSegmentAddress;
4202+
NewPhdr.p_paddr = NewTextSegmentAddress;
42134203
NewPhdr.p_filesz = NewTextSegmentSize;
42144204
NewPhdr.p_memsz = NewTextSegmentSize;
42154205
NewPhdr.p_flags = ELF::PF_X | ELF::PF_R;
@@ -4270,7 +4260,7 @@ void RewriteInstance::patchELFPHDRTable() {
42704260
};
42714261

42724262
auto writeNewSegmentPhdrs = [&]() {
4273-
if (PHDRTableAddress || NewTextSegmentSize) {
4263+
if (NewTextSegmentSize) {
42744264
SmallVector<ELF64LE::Phdr, 3> NewPhdrs = createNewPhdrs();
42754265
OS.write(reinterpret_cast<const char *>(NewPhdrs.data()),
42764266
sizeof(ELF64LE::Phdr) * NewPhdrs.size());

0 commit comments

Comments
 (0)