Skip to content

Commit

Permalink
fix elf and pe flags
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Eckels committed May 25, 2022
1 parent 7791e93 commit 025ea0e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/debug/buildinfo/buildinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,10 @@ func (x *elfExe) DataStart() uint64 {
return s.Addr
}
}

for _, p := range x.f.Progs {
if p.Type == elf.PT_LOAD && p.Flags&(elf.PF_X|elf.PF_W) == elf.PF_W {
flags := elf.ProgFlag(elf.PF_R | elf.PF_W)
if p.Type == elf.PT_LOAD && (p.Flags&flags) == flags {
return p.Vaddr
}
}
Expand Down Expand Up @@ -313,8 +315,8 @@ func (x *peExe) DataStart() uint64 {
IMAGE_SCN_ALIGN_32BYTES = 0x600000
)
for _, sect := range x.f.Sections {
if sect.VirtualAddress != 0 && sect.Size != 0 &&
sect.Characteristics&^IMAGE_SCN_ALIGN_32BYTES == IMAGE_SCN_CNT_INITIALIZED_DATA|IMAGE_SCN_MEM_READ|IMAGE_SCN_MEM_WRITE {
flags := uint32(IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE)
if sect.VirtualAddress != 0 && (sect.Characteristics&flags) == flags {
return uint64(sect.VirtualAddress) + x.imageBase()
}
}
Expand Down

0 comments on commit 025ea0e

Please sign in to comment.