Skip to content

Commit 31c603e

Browse files
committed
chore: make file.go GetCStrings return a map of maps to allow for storing different sections cstrings together
1 parent 8c62f51 commit 31c603e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

file.go

+8-4
Original file line numberDiff line numberDiff line change
@@ -1645,20 +1645,24 @@ func (f *File) GetCString(addr uint64) (string, error) {
16451645
return "", fmt.Errorf("string not found at address %#x", addr)
16461646
}
16471647

1648-
func (f *File) GetCStrings() (map[uint64]string, error) {
1649-
strs := make(map[uint64]string)
1648+
func (f *File) GetCStrings() (map[string]map[string]uint64, error) {
1649+
strs := make(map[string]map[string]uint64)
16501650

16511651
for _, sec := range f.Sections {
1652-
if sec.Flags.IsCstringLiterals() && sec.Name == "__cstring" {
1652+
if sec.Flags.IsCstringLiterals() || sec.Name == "__os_log" {
16531653
off, err := f.GetOffset(sec.Addr)
16541654
if err != nil {
16551655
return nil, fmt.Errorf("failed to get offset for %s.%s: %v", sec.Seg, sec.Name, err)
16561656
}
16571657
dat := make([]byte, sec.Size)
16581658
if _, err = f.ReadAt(dat, int64(off)); err != nil {
16591659
return nil, fmt.Errorf("failed to read cstring data in %s.%s: %v", sec.Seg, sec.Name, err)
1660+
16601661
}
16611662

1663+
section := fmt.Sprintf("%s.%s", sec.Seg, sec.Name)
1664+
strs[section] = make(map[string]uint64)
1665+
16621666
csr := bytes.NewBuffer(dat)
16631667

16641668
for {
@@ -1682,7 +1686,7 @@ func (f *File) GetCStrings() (map[uint64]string, error) {
16821686
continue // skip non-ascii strings
16831687
}
16841688
}
1685-
strs[pos] = s
1689+
strs[section][s] = pos
16861690
}
16871691
}
16881692
}

0 commit comments

Comments
 (0)