Unified · Split
| @@ -224,22 +224,34 @@ static void set_pages_executable(void *ptr, unsigned long length) · 223 unmodified lines | ||
| 224 | 224 | the stabs debug information */ |
| 225 | 225 | static uplong rt_printline(uplong wanted_pc, const char *msg) |
| 226 | 226 | { |
| 227 | − Stab_Sym *sym, *sym_end; | |
| 228 | 227 | char func_name[128], last_func_name[128]; |
| 229 | − unsigned long func_addr, last_pc, pc; | |
| 228 | + uplong func_addr, last_pc, pc; | |
| 230 | 229 | const char *incl_files[INCLUDE_STACK_SIZE]; |
| 231 | 230 | int incl_index, len, last_line_num, i; |
| 232 | 231 | const char *str, *p; |
| 233 | 232 | |
| 233 | + Stab_Sym *stab_sym = NULL, *stab_sym_end, *sym; | |
| 234 | + int stab_len = 0; | |
| 235 | + char *stab_str = NULL; | |
| 236 | + | |
| 237 | + if (stab_section) { | |
| 238 | + stab_len = stab_section->data_offset; | |
| 239 | + stab_sym = (Stab_Sym *)stab_section->data; | |
| 240 | + stab_str = stabstr_section->data; | |
| 241 | + } | |
| 242 | + | |
| 234 | 243 | func_name[0] = '\0'; |
| 235 | 244 | func_addr = 0; |
| 236 | 245 | incl_index = 0; |
| 237 | 246 | last_func_name[0] = '\0'; |
| 238 | − last_pc = 0xffffffff; | |
| 247 | + last_pc = (uplong)-1; | |
| 239 | 248 | last_line_num = 1; |
| 240 | − sym = (Stab_Sym *)stab_section->data + 1; | |
| 241 | − sym_end = (Stab_Sym *)(stab_section->data + stab_section->data_offset); | |
| 242 | − while (sym < sym_end) { | |
| 249 | + | |
| 250 | + if (!stab_sym) | |
| 251 | + goto no_stabs; | |
| 252 | + | |
| 253 | + stab_sym_end = (Stab_Sym*)((char*)stab_sym + stab_len); | |
| 254 | + for (sym = stab_sym + 1; sym < stab_sym_end; ++sym) { | |
| 243 | 255 | switch(sym->n_type) { |
| 244 | 256 | /* function start or end */ |
| 245 | 257 | case N_FUN: |
| @@ -251,7 +263,7 @@ static uplong rt_printline(uplong wanted_pc, const char *msg) · 5 unmodified lines | ||
| 251 | 263 | func_name[0] = '\0'; |
| 252 | 264 | func_addr = 0; |
| 253 | 265 | } else { |
| 254 | − str = stabstr_section->data + sym->n_strx; | |
| 266 | + str = stab_str + sym->n_strx; | |
| 255 | 267 | p = strchr(str, ':'); |
| 256 | 268 | if (!p) { |
| 257 | 269 | pstrcpy(func_name, sizeof(func_name), str); |
| @@ -277,7 +289,7 @@ static uplong rt_printline(uplong wanted_pc, const char *msg) · 19 unmodified lines | ||
| 277 | 289 | break; |
| 278 | 290 | /* include files */ |
| 279 | 291 | case N_BINCL: |
| 280 | − str = stabstr_section->data + sym->n_strx; | |
| 292 | + str = stab_str + sym->n_strx; | |
| 281 | 293 | add_incl: |
| 282 | 294 | if (incl_index < INCLUDE_STACK_SIZE) { |
| 283 | 295 | incl_files[incl_index++] = str; |
| @@ -291,7 +303,7 @@ static uplong rt_printline(uplong wanted_pc, const char *msg) · 7 unmodified lines | ||
| 291 | 303 | if (sym->n_strx == 0) { |
| 292 | 304 | incl_index = 0; /* end of translation unit */ |
| 293 | 305 | } else { |
| 294 | − str = stabstr_section->data + sym->n_strx; | |
| 306 | + str = stab_str + sym->n_strx; | |
| 295 | 307 | /* do not add path */ |
| 296 | 308 | len = strlen(str); |
| 297 | 309 | if (len > 0 && str[len - 1] != '/') |
| @@ -299,11 +311,12 @@ static uplong rt_printline(uplong wanted_pc, const char *msg) · 1 unmodified line | ||
| 299 | 311 | } |
| 300 | 312 | break; |
| 301 | 313 | } |
| 302 | − sym++; | |
| 303 | 314 | } |
| 304 | 315 | |
| 316 | +no_stabs: | |
| 305 | 317 | /* second pass: we try symtab symbols (no line number info) */ |
| 306 | 318 | incl_index = 0; |
| 319 | + if (symtab_section) | |
| 307 | 320 | { |
| 308 | 321 | ElfW(Sym) *sym, *sym_end; |
| 309 | 322 | int type; |