Skip to content

Commit

Permalink
[dumphunk] Correctly parse GNU local symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
cahirwpz committed Dec 16, 2023
1 parent 1435966 commit 2161ddf
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 2 additions & 0 deletions tools/hunk/hunk.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const (
EXT_DEF = 1 // relocatable definition
EXT_ABS = 2 // Absolute definition
EXT_RES = 3 // no longer supported
EXT_GNU_LOCAL = 33 // GNU local symbol definition
EXT_REF32 = 129 // 32 bit absolute reference to symbol
EXT_COMMON = 130 // 32 bit absolute reference to COMMON block
EXT_REF16 = 131 // 16 bit PC-relative reference to symbol
Expand Down Expand Up @@ -103,6 +104,7 @@ func init() {
EXT_DEF: "EXT_DEF",
EXT_ABS: "EXT_ABS",
EXT_RES: "EXT_RES",
EXT_GNU_LOCAL: "EXT_GNU_LOCAL",
EXT_REF32: "EXT_REF32",
EXT_COMMON: "EXT_COMMON",
EXT_REF16: "EXT_REF16",
Expand Down
1 change: 0 additions & 1 deletion tools/hunk/hunk_debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func readStrTab(r io.Reader, size uint32) []byte {
}

func readHunkDebugGnu(r io.Reader, name string) HunkDebugGnu {
fmt.Printf("HunkDebugGnu: %s\n", name)
var stabTab []Stab
var stabstrTab []byte
if name == "" {
Expand Down
4 changes: 2 additions & 2 deletions tools/hunk/hunk_ext.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func readHunkExt(r io.Reader) HunkExt {
extType := ExtType(nlongs >> 24)
name := readStringOfSize(r, length)
switch extType {
case EXT_DEF, EXT_ABS, EXT_RES:
case EXT_DEF, EXT_ABS, EXT_RES, EXT_GNU_LOCAL:
value := readLong(r)
ext = append(ext, Extern{extType, name, value, nil})
case EXT_REF32, EXT_REF16, EXT_REF8, EXT_DEXT32, EXT_DEXT16, EXT_DEXT8:
Expand All @@ -38,7 +38,7 @@ func readHunkExt(r io.Reader) HunkExt {
size := readLong(r)
ext = append(ext, Extern{extType, name, size, readArrayOfLong(r)})
default:
panic("unknown external type")
panic(fmt.Sprintf("unknown external type: %v", extType))
}
}
sort.Slice(ext, func(i, j int) bool {
Expand Down

0 comments on commit 2161ddf

Please sign in to comment.