Skip to content

Commit

Permalink
fix: use same logic for all bss section check
Browse files Browse the repository at this point in the history
Signed-off-by: Zxilly <[email protected]>
  • Loading branch information
Zxilly committed Jun 16, 2024
1 parent 78ee439 commit 61d92f0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions internal/wrapper/macho.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (m *MachoWrapper) LoadSymbols(marker func(name string, addr uint64, size ui
typ = entity.AddrTypeText
}

if sect.Seg == "__DATA" && (sect.Name == "__bss" || sect.Name == "__noptrbss") {
if machoSectionShouldIgnore(sect) {
continue // bss section, skip
}

Expand All @@ -98,7 +98,7 @@ func (m *MachoWrapper) LoadSections() map[string]*entity.Section {

d := strings.HasPrefix(section.Name, "__debug_") || strings.HasPrefix(section.Name, "__zdebug_")

if section.Offset == 0 {
if machoSectionShouldIgnore(section) {
// seems like .bss section
ret[section.Name] = &entity.Section{
Name: section.Name,
Expand Down Expand Up @@ -132,7 +132,11 @@ func (m *MachoWrapper) LoadSections() map[string]*entity.Section {
}

func machoSectionShouldIgnore(sect *macho.Section) bool {
if sect.Name == "__bss" || sect.Offset == 0 {
if sect.Seg == "__DATA" && (sect.Name == "__bss" || sect.Name == "__noptrbss") {
return true
}

if sect.Offset == 0 {
return true
}

Expand Down

0 comments on commit 61d92f0

Please sign in to comment.