Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[BOLT] More refactoring of PHDR handling. NFC#148932

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
maksfb wants to merge1 commit intollvm:main
base:main
Choose a base branch
Loading
frommaksfb:gh-phdrs

Conversation

maksfb
Copy link
Contributor

Replace ad-hoc adjustment of the program header count with info from the new segment list.

Replace ad-hoc adjustment of the program header count with info from thenew segment list.
@llvmbot
Copy link
Member

@llvm/pr-subscribers-bolt

Author: Maksim Panchenko (maksfb)

Changes

Replace ad-hoc adjustment of the program header count with info from the new segment list.


Full diff:https://github.com/llvm/llvm-project/pull/148932.diff

1 Files Affected:

  • (modified) bolt/lib/Rewrite/RewriteInstance.cpp (+12-18)
diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cppindex 96045a916232c..f1b94e4a821a6 100644--- a/bolt/lib/Rewrite/RewriteInstance.cpp+++ b/bolt/lib/Rewrite/RewriteInstance.cpp@@ -4260,31 +4260,25 @@ void RewriteInstance::patchELFPHDRTable() {   const ELFFile<ELF64LE> &Obj = ELF64LEFile->getELFFile();   raw_fd_ostream &OS = Out->os();-  // Write/re-write program headers.   Phnum = Obj.getHeader().e_phnum;-  if (PHDRTableOffset) {-    // Writing new pheader table and adding one new entry for R+X segment.-    Phnum += 1;-    if (NewWritableSegmentSize) {-      // Adding one more entry for R+W segment.-      Phnum += 1;-    }-  } else {++  if (BC->NewSegments.empty()) {+    BC->outs() << "BOLT-INFO: not adding new segments\n";+    return;+  }++  if (opts::UseGnuStack) {     assert(!PHDRTableAddress && "unexpected address for program header table");-    PHDRTableOffset = Obj.getHeader().e_phoff;-    if (NewWritableSegmentSize) {+    if (BC->NewSegments.size() > 1) {       BC->errs() << "BOLT-ERROR: unable to add writable segment\n";       exit(1);     }+  } else {+    Phnum += BC->NewSegments.size();   }-  if (opts::Instrument)-    Phnum += 2;--  if (BC->NewSegments.empty()) {-    BC->outs() << "BOLT-INFO: not adding new segments\n";-    return;-  }+  if (!PHDRTableOffset)+    PHDRTableOffset = Obj.getHeader().e_phoff;    const uint64_t SavedPos = OS.tell();   OS.seek(PHDRTableOffset);

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@aaupovaaupovaaupov approved these changes

@rafaelaulerrafaelaulerAwaiting requested review from rafaelaulerrafaelauler is a code owner

@ayermoloayermoloAwaiting requested review from ayermoloayermolo is a code owner

@yota9yota9Awaiting requested review from yota9yota9 is a code owner

@paschalis-mpeispaschalis-mpeisAwaiting requested review from paschalis-mpeispaschalis-mpeis is a code owner

Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@maksfb@llvmbot@aaupov

[8]ページ先頭

©2009-2025 Movatter.jp