get rid of debug-info in ELF-file
get rid of debug-info in ELF-file
could anyone tell my how to get rid of the debug-info in a compiled elf-file? - i mean the function-names/labels/symbols or whatever they are called - what you see, when you dissassemble it. what compiler flag to set or to remove?
thanks
thanks
infj
You can also use the -s option on gcc's command line to strip those at link time.
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
-s in a link strips all the symbols, not just the debug info. This may be what you want, but renders an "nm" quite useless and makes debugging harder. You might also ensure that you don't use -g. Failing that, if you run a "size -Ax" and see all those tasty "debug_*" sections, then you can always provide your own linker script and add a " * ( debug_* )" to the DISCARD pile.
Personally, for both the EE & IOP I always use -g (with -O0 or -O2 so as to not confuse gdb & me too much). I have two targets: one with a -s to produce the smallest executable possible which gets fed to the iron and the other leaving everything alone that I feed to gdb in order to debug. YMMV.
tjd
Personally, for both the EE & IOP I always use -g (with -O0 or -O2 so as to not confuse gdb & me too much). I have two targets: one with a -s to produce the smallest executable possible which gets fed to the iron and the other leaving everything alone that I feed to gdb in order to debug. YMMV.
tjd
Stripping is a linker function. If you are trying to strip from the gcc line, you have to use "-Wl,-s" or "-Wl,-S". This tells gcc to pass the -s or -S to the linker.
So your line in the makefile might be something like this:
gcc [email protected] -o $@ -Wl,-s $(LIBS)
So your line in the makefile might be something like this:
gcc [email protected] -o $@ -Wl,-s $(LIBS)
yes gcc -s and gcc -Wl,-s are "supposed" to be different. Indeed, when you wsant to look at the assembler code, gcc -s foo.c is a good thing.
But (isn't there always one?). 'Splain this:
Looks stripped to me. Anyway, there seems to be a difference in the way things are operating if invoked as part of the link phase, vs. a strip.
But (isn't there always one?). 'Splain this:
Code: Select all
[broadq@mcv-1-1-1 poweroff]$ make
ps2-gcc -o poweroff.irx -s -G0 -g -miop -nostdlib -nostartfiles test.iop.o poweroff.iop.o scmd.iop.o vblank_poweroff.iop.o mediostub.iop.o -L/home/broadq/src/ps2lib-2.1/iop/lib -lkernel -lgcc
ps2-gcc -o poweroff.full.irx -G0 -g -miop -nostdlib -nostartfiles test.iop.o poweroff.iop.o scmd.iop.o vblank_poweroff.iop.o mediostub.iop.o -L/home/broadq/src/ps2lib-2.1/iop/lib -lkernel -lgcc
[broadq@mcv-1-1-1 poweroff]$ file *irx
poweroff.full.irx: ELF 32-bit LSB mips-1 processor-specific, MIPS R3000_LE [bfd bug], version 1 MathCoPro/FPU/MAU Required (SYSV), not stripped
poweroff.irx: ELF 32-bit LSB mips-1 processor-specific, MIPS R3000_LE [bfd bug], version 1 MathCoPro/FPU/MAU Required (SYSV), stripped
[broadq@mcv-1-1-1 poweroff]$
gcc manual wrote: -s Remove all symbol table and relocation information from the executable.
Shoot Pixels Not People!
Makeshift Development
Makeshift Development
-
- Posts: 564
- Joined: Sat Jan 17, 2004 10:22 am
- Location: Sweden
- Contact:
[quote="tjd"]yes gcc -s and gcc -Wl,-s are "supposed" to be different. Indeed, when you wsant to look at the assembler code, gcc -s foo.c is a good thing.
[/code]
I suppose you meant
-S Stop after the stage of compilation proper; do not assemble. The output is
an assembler code file for each non-assembler input file specified.
[/code]
I suppose you meant
-S Stop after the stage of compilation proper; do not assemble. The output is
an assembler code file for each non-assembler input file specified.
Kung VU
Anyway, if you REALLY want very strict stripping code, then, look at ps2-packer and sjuncrunch code. The idea would be to load all the PT_LOAD sections (just what ps2-packer does), and write a new ELF with only program header sections (just what sjuncrunch does). You can also change the writer part by shorting up the header size. The default 0x1000 bytes is a bit too much, and it can be reduced to something much smaller.
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.