Skip to content

Commit

Permalink
Merge pull request #2 from sleirsgoevy/data-fix
Browse files Browse the repository at this point in the history
Fix missing PT_LOAD segment for .data
  • Loading branch information
nkrapivin authored Dec 24, 2021
2 parents 0b1fe04 + 46e9b38 commit 30d2e10
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion pkg/oelf/OELFGenProgramHeaders.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,20 @@ func (orbisElf *OrbisElf) GenerateProgramHeaders() error {
// PT_LOAD for relro will be handled by SCE_RELRO, we can get rid of it
if gnuRelroSegment != nil {
if progHeader.Type == elf.PT_LOAD && progHeader.Off == gnuRelroSegment.Off {
continue
if progHeader.Memsz > (gnuRelroSegment.Memsz + 0x3fff) & ^uint64(0x4000) {
subtractSize := (gnuRelroSegment.Memsz + 0x3fff) & ^uint64(0x4000)
progHeader.Off += subtractSize
progHeader.Vaddr += subtractSize
progHeader.Paddr = 0
if progHeader.Filesz < subtractSize {
progHeader.Filesz = 0
} else {
progHeader.Filesz -= subtractSize
}
progHeader.Memsz -= subtractSize
} else {
continue
}
}
}

Expand Down

0 comments on commit 30d2e10

Please sign in to comment.