Re: RFC: Idea for code size reduction

2009-01-23 Thread Philipp Marek
Hello everybody, On Friday 07 March 2008 Philipp Marek wrote: > Here you are. > > > code_overlap.pl - disassembles a binary, and outputs a list > (address, name, instruction, bytes) to STDOUT. > > bytes_saved.pl - takes such a list, and tries to estimate > the amount of bytes that could be sav

Re: Idea for code size reduction

2008-03-07 Thread Philipp Marek
On Friday 07 March 2008 Ian Lance Taylor wrote: > "Philipp Marek" <[EMAIL PROTECTED]> writes: > >> Shouldn't this be done in the linker instead? > > > > Well, can the linker change the instruction sequences? Ie. put a JMP > > instead of other code? > > Sure. The linker can do whatever it likes.

Re: Idea for code size reduction

2008-03-07 Thread Ian Lance Taylor
"Philipp Marek" <[EMAIL PROTECTED]> writes: >> Shouldn't this be done in the linker instead? > Well, can the linker change the instruction sequences? Ie. put a JMP > instead of other code? Sure. The linker can do whatever it likes. The usual problem is that by the time the linker sees the cod

Re: RFC: Idea for code size reduction

2008-03-07 Thread Philipp Marek
BTW - It gets much better: $ ls -la /usr/lib/libgcj.so.90.0.0 -rw-r--r-- 1 root root 32844984 3. Feb 16:03 /usr/lib/libgcj.so.90.0.0 $ ./run /usr/lib/libgcj.so.90.0.0 Approx. 470045 bytes saved. That's 1.4% :-) If my script isn't buggy, that is -- Versioning your /etc, /home or

Re: RFC: Idea for code size reduction

2008-03-07 Thread Philipp Marek
Hello Jakub! >> When wouldn't that possible? My script currently splits on an >> instruction-level -- although I would see no problem that some branch >> jumps into a "half" opcode of another branch, if the byte sequence >> matches. > > Consider: > : >0: b8 a4 00 00 00

Re: RFC: Idea for code size reduction

2008-03-07 Thread Jakub Jelinek
On Fri, Mar 07, 2008 at 01:05:03PM +0100, Philipp Marek wrote: > When wouldn't that possible? My script currently splits on an > instruction-level -- although I would see no problem that some branch > jumps into a "half" opcode of another branch, if the byte sequence > matches. Consider:

Re: RFC: Idea for code size reduction

2008-03-07 Thread Richard Guenther
On Fri, Mar 7, 2008 at 12:46 PM, Jakub Jelinek <[EMAIL PROTECTED]> wrote: > On Fri, Mar 07, 2008 at 11:10:53AM +0100, Richard Guenther wrote: > > On Fri, Mar 7, 2008 at 11:02 AM, Philipp Marek <[EMAIL PROTECTED]> wrote: > > > > I wrote some perl scripts to test this. I took a "alldefconfig" i686

Re: RFC: Idea for code size reduction

2008-03-07 Thread Philipp Marek
Hello Jakub! > You need to be very careful with it, as if there are any jumps > into the middle of the to be abstracted tail sequences, you can't > abstract them or would need to adjust also the jumps into them (if > possible, which not always is). When wouldn't that possible? My script currently

RE: Idea for code size reduction

2008-03-07 Thread Philipp Marek
Hello Dave! > One achitectural problem here is that GCC doesn't emit bytes. It emits > ASCII text, in the form of assembly instructions, and it's > not always easy to predict how they'll look by the time they've been > through the assembler and then had relocs applied by the > linker. (Indeed, to

Re: RFC: Idea for code size reduction

2008-03-07 Thread Jakub Jelinek
On Fri, Mar 07, 2008 at 11:10:53AM +0100, Richard Guenther wrote: > On Fri, Mar 7, 2008 at 11:02 AM, Philipp Marek <[EMAIL PROTECTED]> wrote: > > I wrote some perl scripts to test this. I took a "alldefconfig" i686 > > kernel, let objdump disassemble it, and on "iret", "ret", "ljmp" or "jmp" > >

RE: Idea for code size reduction

2008-03-07 Thread Dave Korn
Philipp Marek wrote: > I'd like to (manually) define some byte blocks, eg. as functions with > an identifier. Then, if GCC would emit exactly these bytes, it > puts a JMP identifier there instead. One achitectural problem here is that GCC doesn't emit bytes. It emits ASCII text, in the form

Re: RFC: Idea for code size reduction

2008-03-07 Thread Philipp Marek
Hello Michael! > Can I test your script in my embedded system? > Can you send to me? Here you are. code_overlap.pl - disassembles a binary, and outputs a list (address, name, instruction, bytes) to STDOUT. bytes_saved.pl - takes such a list, and tries to estimate the amount of bytes that c

Re: RFC: Idea for code size reduction

2008-03-07 Thread Philipp Marek
Hello Richard! [ I took linux-tiny out - it's moderated, and I don't want to spam them. ] > Sounds like what -frtl-abstract-sequences is trying to do. Yes, thank you. I didn't know that; that should be close. *But*: I think it doesn't work. $ size vmlinux-as vmlinux-Os textdata b

Re: RFC: Idea for code size reduction

2008-03-07 Thread michael
Hi, Philipp Marek wrote: Hello everybody, I have a feature request. and my scripts emit space savings of about 30kB. Now that's not that much, but for embedded systems it means another userspace binary more. [ If anyone's interested, I can post my scripts here ... they're not that large.

Re: RFC: Idea for code size reduction

2008-03-07 Thread Richard Guenther
On Fri, Mar 7, 2008 at 11:02 AM, Philipp Marek <[EMAIL PROTECTED]> wrote: > Hello everybody, > > I have a feature request. > > > I'd like to (manually) define some byte blocks, eg. as functions with an > identifier. Then, if GCC would emit exactly these bytes, it puts a JMP > identifier there

RFC: Idea for code size reduction

2008-03-07 Thread Philipp Marek
Hello everybody, I have a feature request. I'd like to (manually) define some byte blocks, eg. as functions with an identifier. Then, if GCC would emit exactly these bytes, it puts a JMP identifier there instead. This would help by sharing many identical (text/code) byte sequences, to make a s