File tree Expand file tree Collapse file tree 1 file changed +12
-18
lines changed Expand file tree Collapse file tree 1 file changed +12
-18
lines changed Original file line number Diff line number Diff line change @@ -4260,31 +4260,25 @@ void RewriteInstance::patchELFPHDRTable() {
4260
4260
const ELFFile<ELF64LE> &Obj = ELF64LEFile->getELFFile ();
4261
4261
raw_fd_ostream &OS = Out->os ();
4262
4262
4263
- // Write/re-write program headers.
4264
4263
Phnum = Obj.getHeader ().e_phnum ;
4265
- if (PHDRTableOffset) {
4266
- // Writing new pheader table and adding one new entry for R+X segment.
4267
- Phnum += 1 ;
4268
- if (NewWritableSegmentSize) {
4269
- // Adding one more entry for R+W segment.
4270
- Phnum += 1 ;
4271
- }
4272
- } else {
4264
+
4265
+ if (BC->NewSegments .empty ()) {
4266
+ BC->outs () << " BOLT-INFO: not adding new segments\n " ;
4267
+ return ;
4268
+ }
4269
+
4270
+ if (opts::UseGnuStack) {
4273
4271
assert (!PHDRTableAddress && " unexpected address for program header table" );
4274
- PHDRTableOffset = Obj.getHeader ().e_phoff ;
4275
- if (NewWritableSegmentSize) {
4272
+ if (BC->NewSegments .size () > 1 ) {
4276
4273
BC->errs () << " BOLT-ERROR: unable to add writable segment\n " ;
4277
4274
exit (1 );
4278
4275
}
4276
+ } else {
4277
+ Phnum += BC->NewSegments .size ();
4279
4278
}
4280
4279
4281
- if (opts::Instrument)
4282
- Phnum += 2 ;
4283
-
4284
- if (BC->NewSegments .empty ()) {
4285
- BC->outs () << " BOLT-INFO: not adding new segments\n " ;
4286
- return ;
4287
- }
4280
+ if (!PHDRTableOffset)
4281
+ PHDRTableOffset = Obj.getHeader ().e_phoff ;
4288
4282
4289
4283
const uint64_t SavedPos = OS.tell ();
4290
4284
OS.seek (PHDRTableOffset);
You can’t perform that action at this time.
0 commit comments