| View previous topic :: View next topic |
| Author |
Message |
Saotome

Joined: 03 Apr 2004 Posts: 182
|
Posted: Sat Aug 14, 2004 6:08 am Post subject: 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 _________________ infj |
|
| Back to top |
|
 |
mrbrown
Joined: 17 Jan 2004 Posts: 1536
|
Posted: Sat Aug 14, 2004 6:24 am Post subject: |
|
|
ee-strip -o final-stripped.elf final.elf
If you don't need the symbols at all in the original ELF, you can omit the -o parameter. _________________ "He was warned..." |
|
| Back to top |
|
 |
pixel
Joined: 30 Jan 2004 Posts: 791
|
Posted: Sat Aug 14, 2004 7:02 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
Saotome

Joined: 03 Apr 2004 Posts: 182
|
Posted: Sat Aug 14, 2004 7:45 am Post subject: |
|
|
thanks very much, both of you
already thought that the final-elf will be smaller, but didnt expect that much: 120kB -> 46kB :) _________________ infj |
|
| Back to top |
|
 |
tjd
Joined: 27 May 2004 Posts: 23 Location: Austin, TX
|
Posted: Mon Sep 06, 2004 10:07 pm Post subject: |
|
|
-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 |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Tue Sep 07, 2004 7:13 am Post subject: |
|
|
| Use -S to strip just the debug symbols. Lower case = all symbols, upper case = just debug symbols. |
|
| Back to top |
|
 |
tjd
Joined: 27 May 2004 Posts: 23 Location: Austin, TX
|
Posted: Thu Sep 09, 2004 10:26 pm Post subject: |
|
|
strip -s -S
yeah, but it doesn't work with gcc-3.2.2 (loads of error messages and the resulting file is trash), but -s does work with gcc/g++/ld... Go figure. |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Fri Sep 10, 2004 12:08 pm Post subject: |
|
|
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 $@.o -o $@ -Wl,-s $(LIBS) |
|
| Back to top |
|
 |
mrbrown
Joined: 17 Jan 2004 Posts: 1536
|
Posted: Fri Sep 10, 2004 5:08 pm Post subject: |
|
|
Stripping is not just a linker function. The linker is never invoked when you do "gcc -s -c myfile.c -o foo.o". Technically, "gcc -s" and "gcc -Wl,-s" are too different things, but I'll let the GCC and binutils manuals sort that out for you :P. _________________ "He was warned..." |
|
| Back to top |
|
 |
tjd
Joined: 27 May 2004 Posts: 23 Location: Austin, TX
|
Posted: Fri Sep 10, 2004 9:48 pm Post subject: |
|
|
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:
| Code: | [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]$ |
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. |
|
| Back to top |
|
 |
Drakonite Site Admin

Joined: 17 Jan 2004 Posts: 989
|
Posted: Fri Sep 10, 2004 10:07 pm Post subject: |
|
|
| gcc manual wrote: |
-s Remove all symbol table and relocation information from the executable.
|
_________________ Shoot Pixels Not People!
Makeshift Development |
|
| Back to top |
|
 |
blackdroid
Joined: 17 Jan 2004 Posts: 564 Location: Sweden
|
Posted: Sat Sep 11, 2004 1:06 am Post subject: |
|
|
[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. _________________ Kung VU |
|
| Back to top |
|
 |
tjd
Joined: 27 May 2004 Posts: 23 Location: Austin, TX
|
Posted: Sat Sep 11, 2004 1:14 am Post subject: |
|
|
| yes, -S is what my fingers should have typed... It's been a long night. But we all digress. My point a while back is that an IRX produced from "gcc -s ..." and "strip ..." do not appear to create the same file. The results of the "strip" are garbage. (all this from gcc-3.2.2 and binutils 2.14) |
|
| Back to top |
|
 |
pixel
Joined: 30 Jan 2004 Posts: 791
|
Posted: Sat Sep 11, 2004 3:05 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
tjd
Joined: 27 May 2004 Posts: 23 Location: Austin, TX
|
Posted: Sat Sep 11, 2004 11:17 pm Post subject: |
|
|
| Well, thanks. But objcopy to a raw file and zip/unzip works nicely too ;-) |
|
| Back to top |
|
 |
|