Search code examples
gccassemblyarmgnu-assembler

Why doesn't "strip" remove these debug symbols?


I have a simple assembly file main.s which contains:

mysymbol1=1234

I assemble it into an object file using the following command:

$ arm-none-eabi-as main.s -o main.o

Now I check the symbol table

$ arm-none-eabi-objdump -t main.o

main.o:     file format elf32-littlearm

SYMBOL TABLE:
00000000 l    d  .text  00000000 .text
00000000 l    d  .data  00000000 .data
00000000 l    d  .bss   00000000 .bss
000004d2 l       *ABS*  00000000 mysymbol1
00000000 l    d  .ARM.attributes    00000000 .ARM.attributes

I note that the d indicates that there are debug symbols included so I run:

$ arm-none-eabi-strip --strip-debug main.o

Re-running objdump shows that the debug symbols have not been removed, although they have been reordered:

$ arm-none-eabi-objdump -t main.o

main.o:     file format elf32-littlearm

SYMBOL TABLE:
000004d2 l       *ABS*  00000000 mysymbol1
00000000 l    d  .text  00000000 .text
00000000 l    d  .data  00000000 .data
00000000 l    d  .bss   00000000 .bss
00000000 l    d  .ARM.attributes    00000000 .ARM.attributes

Why aren't the debug symbols removed?


Solution

  • .text, .data and .bss are not debug symbols - they are file segments which are used by kernel to properly execute it. mysymbol1 comes from static symbol table and thus is not part of debuginfo so it's not stripped under --strip-debug either.