3

I want to break at a local label in NASM assembly code using GDB.

Issuing the following command yields the output:

   (gdb) break *start.label1 + 217
    Attempt to extract a component of a value that is not a structure.

Here my code goes something like this:

global _start
_start:
...
.label1:
...

How can I break at local .label1?

Shuzheng
  • 11,288
  • 20
  • 88
  • 186
  • 2
    To break at a label, you shouldn't dereference it `b start.label1`, just like `b main`. Maybe `b (start.label1 + 217)` would work. With a dereference, you might need `b *(start.label1 + 217)`. But IDK if gdb supports `.` inside symbol names, which `nm` says is the actual symbol name. You might have to `b *0x...` and copy/paste the address. Sorry don't have time to write an answer. – Peter Cordes Aug 14 '16 at 18:16
  • Thanks for your suggestions :) – Shuzheng Aug 14 '16 at 19:42
  • 4
    Put the label with the period inside of single quotes in the expression. Something like `b *'start.label1' + 217` – Michael Petch Aug 14 '16 at 21:29
  • GNU GAS ELF version of this question: https://stackoverflow.com/questions/55226798/how-to-make-local-labels-in-gnu-gas-elf-output-that-gdb-can-break-on-but-not-cou – Ciro Santilli OurBigBook.com Mar 18 '19 at 17:21

1 Answers1

-1

Disassemble the function where your local label is called, select the address and add a break as you normally would with the address, not the label name. You can also disassemble by the address for local labels.