Projects STRLCPY GoReSym Commits 8a8c5006
🤬
  • Resolve #3. Pass section base of text section instead of section containing pclntab

  • Loading...
  • Stephen Eckels committed 2 years ago
    8a8c5006
    1 parent 9d2d6c56
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■ ■
    objfile/elf.go
    skipped 116 lines
    117 117   
    118 118   var candidate PclntabCandidate
    119 119   candidate.pclntab = pclntab
    120  - candidate.secStart = uint64(sec.Addr)
    121  - candidate.pclntabVA = candidate.secStart + uint64(pclntab_idx)
     120 + candidate.pclntabVA = uint64(sec.Addr) + uint64(pclntab_idx)
    122 121   
    123 122   candidates = append(candidates, candidate)
    124 123   // we must scan all signature for all sections. DO NOT BREAK
    skipped 5 lines
    130 129   if pclntab_idx != -1 && pclntab_idx < int(sec.Size) {
    131 130   var candidate PclntabCandidate
    132 131   candidate.pclntab = pclntab
    133  - candidate.secStart = uint64(sec.Addr)
    134  - candidate.pclntabVA = candidate.secStart + uint64(pclntab_idx)
     132 + candidate.pclntabVA = uint64(sec.Addr) + uint64(pclntab_idx)
    135 133   
    136 134   candidates = append(candidates, candidate)
    137 135   break ExitScan
    skipped 180 lines
  • ■ ■ ■ ■ ■ ■
    objfile/macho.go
    skipped 134 lines
    135 135   
    136 136   var candidate PclntabCandidate
    137 137   candidate.pclntab = pclntab
    138  - candidate.secStart = uint64(sec.Addr)
    139  - candidate.pclntabVA = candidate.secStart + uint64(pclntab_idx)
     138 + candidate.pclntabVA = uint64(sec.Addr) + uint64(pclntab_idx)
    140 139   
    141 140   candidates = append(candidates, candidate)
    142 141   // we must scan all signature for all sections. DO NOT BREAK
    skipped 5 lines
    148 147   if pclntab_idx != -1 {
    149 148   var candidate PclntabCandidate
    150 149   candidate.pclntab = pclntab
    151  - candidate.secStart = uint64(sec.Addr)
    152  - candidate.pclntabVA = candidate.secStart + uint64(pclntab_idx)
     150 + candidate.pclntabVA = uint64(sec.Addr) + uint64(pclntab_idx)
    153 151   
    154 152   candidates = append(candidates, candidate)
    155 153   
    skipped 162 lines
  • ■ ■ ■ ■ ■
    objfile/objfile.go
    skipped 22 lines
    23 23  )
    24 24   
    25 25  type PclntabCandidate struct {
    26  - secStart uint64
    27 26   pclntabVA uint64
    28 27   pclntab []byte
    29 28   symtab []byte // optional
    skipped 176 lines
    206 205   return nil, 0, err
    207 206   }
    208 207   
     208 + // resolve text start by either symbol or section name
     209 + textStart := uint64(0)
     210 + syms, err := e.raw.symbols()
     211 + if err == nil {
     212 + for _, s := range syms {
     213 + if s.Name == "runtime.text" {
     214 + textStart = s.Addr
     215 + break
     216 + }
     217 + }
     218 + } else {
     219 + secBase, _, err := e.Text()
     220 + if err == nil {
     221 + textStart = secBase
     222 + }
     223 + }
     224 + 
    209 225   for _, candidate := range candidates {
    210  - table, err := gosym.NewTable(candidate.symtab, gosym.NewLineTable(candidate.pclntab, candidate.secStart))
     226 + table, err := gosym.NewTable(candidate.symtab, gosym.NewLineTable(candidate.pclntab, textStart))
    211 227   if err != nil || table.Go12line == nil {
    212 228   continue
    213 229   }
    skipped 1325 lines
  • ■ ■ ■ ■ ■ ■
    objfile/pe.go
    skipped 169 lines
    170 170   
    171 171   var candidate PclntabCandidate
    172 172   candidate.pclntab = pclntab
    173  - candidate.secStart = imageBase + uint64(sec.VirtualAddress)
    174  - candidate.pclntabVA = candidate.secStart + uint64(pclntab_idx)
     173 + candidate.pclntabVA = imageBase + uint64(sec.VirtualAddress) + uint64(pclntab_idx)
    175 174   
    176 175   candidates = append(candidates, candidate)
    177 176   // we must scan all signature for all sections. DO NOT BREAK
    skipped 5 lines
    183 182   if pclntab_idx != -1 && pclntab_idx < int(sec.Size) {
    184 183   var candidate PclntabCandidate
    185 184   candidate.pclntab = pclntab
    186  - candidate.secStart = imageBase + uint64(sec.VirtualAddress)
    187  - candidate.pclntabVA = candidate.secStart + uint64(pclntab_idx)
     185 + candidate.pclntabVA = imageBase + uint64(sec.VirtualAddress) + uint64(pclntab_idx)
    188 186   
    189 187   candidates = append(candidates, candidate)
    190 188   break ExitScan
    skipped 226 lines
Please wait...
Page is in error, reload to recover