forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

get rid of debug-info in ELF-file

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 Development
View previous topic :: View next topic  
Author Message
Saotome



Joined: 03 Apr 2004
Posts: 182

PostPosted: Sat Aug 14, 2004 6:08 am    Post subject: get rid of debug-info in ELF-file Reply with quote

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
View user's profile Send private message
mrbrown



Joined: 17 Jan 2004
Posts: 1536

PostPosted: Sat Aug 14, 2004 6:24 am    Post subject: Reply with quote

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
View user's profile Send private message
pixel



Joined: 30 Jan 2004
Posts: 791

PostPosted: Sat Aug 14, 2004 7:02 am    Post subject: Reply with quote

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
View user's profile Send private message
Saotome



Joined: 03 Apr 2004
Posts: 182

PostPosted: Sat Aug 14, 2004 7:45 am    Post subject: Reply with quote

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
View user's profile Send private message
tjd



Joined: 27 May 2004
Posts: 23
Location: Austin, TX

PostPosted: Mon Sep 06, 2004 10:07 pm    Post subject: Reply with quote

-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
View user's profile Send private message Visit poster's website
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Tue Sep 07, 2004 7:13 am    Post subject: Reply with quote

Use -S to strip just the debug symbols. Lower case = all symbols, upper case = just debug symbols.
Back to top
View user's profile Send private message AIM Address
tjd



Joined: 27 May 2004
Posts: 23
Location: Austin, TX

PostPosted: Thu Sep 09, 2004 10:26 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Fri Sep 10, 2004 12:08 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
mrbrown



Joined: 17 Jan 2004
Posts: 1536

PostPosted: Fri Sep 10, 2004 5:08 pm    Post subject: Reply with quote

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
View user's profile Send private message
tjd



Joined: 27 May 2004
Posts: 23
Location: Austin, TX

PostPosted: Fri Sep 10, 2004 9:48 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Drakonite
Site Admin


Joined: 17 Jan 2004
Posts: 989

PostPosted: Fri Sep 10, 2004 10:07 pm    Post subject: Reply with quote

gcc manual wrote:

-s Remove all symbol table and relocation information from the executable.

_________________
Shoot Pixels Not People!
Makeshift Development
Back to top
View user's profile Send private message Visit poster's website
blackdroid



Joined: 17 Jan 2004
Posts: 564
Location: Sweden

PostPosted: Sat Sep 11, 2004 1:06 am    Post subject: Reply with quote

[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
View user's profile Send private message Visit poster's website
tjd



Joined: 27 May 2004
Posts: 23
Location: Austin, TX

PostPosted: Sat Sep 11, 2004 1:14 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
pixel



Joined: 30 Jan 2004
Posts: 791

PostPosted: Sat Sep 11, 2004 3:05 am    Post subject: Reply with quote

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
View user's profile Send private message
tjd



Joined: 27 May 2004
Posts: 23
Location: Austin, TX

PostPosted: Sat Sep 11, 2004 11:17 pm    Post subject: Reply with quote

Well, thanks. But objcopy to a raw file and zip/unzip works nicely too ;-)
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group