Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Why is my 64bit executable so large?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo on Sparc
View previous topic :: View next topic  
Author Message
alexbuell
Guru
Guru


Joined: 18 Jul 2002
Posts: 490
Location: "Hemp"shire, UK

PostPosted: Wed Dec 27, 2006 8:03 pm    Post subject: Why is my 64bit executable so large? Reply with quote

My code:
Code:

.equ SYSCALL_EXIT, 1
.equ SYSCALL_WRITE, 4

.equ STDIN, 0
.equ STDOUT, 1
.equ STDERR, 2

        .align 4
        .global _start

_start:
        mov STDOUT, %o0
        set string, %o1
        mov 14, %o2
        mov SYSCALL_WRITE, %g1
        ta 0x10

        mov 0, %o0
        mov SYSCALL_EXIT, %g1
        ta 0x10

        .align 4

string:
.ascii  "Hello world!\n"


How I build it:
Code:

as -64 -o hello.o hello.s
ld -e _start --oformat=elf64-sparc -o hello hello.o
ld: warning: sparc:v9 architecture of input file `hello.o' is
incompatible with sparc output strip hello

file hello
hello: ELF 64-bit MSB executable, SPARC V9, version 1 (SYSV),
statically linked, stripped

ls -l
total 24
-rwxr-xr-x 1 root root 66032 2006-12-26 14:39 hello
-rw-r--r-- 1 root root  1056 2006-12-26 14:39 hello.o
-rw-r--r-- 1 root root   296 2006-12-25 10:07 hello.s
-rw-r--r-- 1 root root   187 2006-12-25 10:27 Makefile


Why is the hello executable 66,032 bytes long? Answers would be gratefully received.
_________________
Cheers,
Alex.

Linux - the best text adventure game ever.
Back to top
View user's profile Send private message
erik258
Advocate
Advocate


Joined: 12 Apr 2005
Posts: 2650
Location: Twin Cities, Minnesota, USA

PostPosted: Thu Dec 28, 2006 6:02 am    Post subject: Reply with quote

i don't know how to do that neat asm stuff, but i tried what you did and got ...(i named it as.s for some strange reason)...

dan@pascal ~ $ as -64 -o hello.o as.s
as.s: Assembler messages:
as.s:12: Error: bad register name `%o0'
as.s:13: Error: no such instruction: `set string,%o1'
as.s:14: Error: bad register name `%o2'
as.s:15: Error: bad register name `%g1'
as.s:16: Error: no such instruction: `ta 0x10'
as.s:18: Error: bad register name `%o0'
as.s:19: Error: bad register name `%g1'
as.s:20: Error: no such instruction: `ta 0x10'
dan@pascal ~ $ cat as.s
.equ SYSCALL_EXIT, 1
.equ SYSCALL_WRITE, 4

.equ STDIN, 0
.equ STDOUT, 1
.equ STDERR, 2

.align 4
.global _start

_start:
mov STDOUT, %o0
set string, %o1
mov 14, %o2
mov SYSCALL_WRITE, %g1
ta 0x10

mov 0, %o0
mov SYSCALL_EXIT, %g1
ta 0x10

.align 4

string:
.ascii "Hello world!\n"

anyway, 64bit means all the default types are now 8 bytes long . But char is still i byte long my research (printf on sizeof(char) ) leads me to believe. I assume all the registers are 64 bit and so on and so forth. I wanted to compare to size of 32bit version but couldn't assemble or whatever its called the source you posted.
_________________
Configuring a Firewall? Try my iptables configuration
LinuxCommando.com is my blog for linux-related scraps and tidbits. Stop by for a visit!
Back to top
View user's profile Send private message
coolsnowmen
Veteran
Veteran


Joined: 30 Jun 2004
Posts: 1479
Location: No.VA

PostPosted: Thu Dec 28, 2006 2:41 pm    Post subject: Re: Why is my 64bit executable so large? Reply with quote

alexbuell wrote:


hello: ELF 64-bit MSB executable, SPARC V9, version 1 (SYSV),
statically linked, stripped


@erik258
Quote:
as.s: Assembler messages:
as.s:12: Error: bad register name `%o0'
as.s:13: Error: no such instruction: `set string,%o1'


Do you have a spark?, this might not compile on a amd64/x86/emt64/IA64 machine
_________________
emerge: there are no ebuilds to satisfy "moo"
Back to top
View user's profile Send private message
erik258
Advocate
Advocate


Joined: 12 Apr 2005
Posts: 2650
Location: Twin Cities, Minnesota, USA

PostPosted: Thu Dec 28, 2006 4:23 pm    Post subject: Reply with quote

well all right. ; (

The thin that probably really increases the exe size is this :
your computer wrote:
statically linked

unless it's not actaully linked to anything?
_________________
Configuring a Firewall? Try my iptables configuration
LinuxCommando.com is my blog for linux-related scraps and tidbits. Stop by for a visit!
Back to top
View user's profile Send private message
alexbuell
Guru
Guru


Joined: 18 Jul 2002
Posts: 490
Location: "Hemp"shire, UK

PostPosted: Fri Dec 29, 2006 10:27 am    Post subject: Reply with quote

erik258 wrote:
well all right. ; (

The thin that probably really increases the exe size is this :
your computer wrote:
statically linked

unless it's not actaully linked to anything?


I think you might be correct, I've asked about this elsewhere. For the record, I intend to try and get 64bit userland up and running under my Ultra 2. I do have 2GB of RAM... the binutils are already able to generate 64bit code, it's the rest of the GCC tool chain that needs to build 64bit code.
_________________
Cheers,
Alex.

Linux - the best text adventure game ever.
Back to top
View user's profile Send private message
erik258
Advocate
Advocate


Joined: 12 Apr 2005
Posts: 2650
Location: Twin Cities, Minnesota, USA

PostPosted: Fri Dec 29, 2006 9:42 pm    Post subject: Reply with quote

have you ever heard of crossdev?
_________________
Configuring a Firewall? Try my iptables configuration
LinuxCommando.com is my blog for linux-related scraps and tidbits. Stop by for a visit!
Back to top
View user's profile Send private message
alexbuell
Guru
Guru


Joined: 18 Jul 2002
Posts: 490
Location: "Hemp"shire, UK

PostPosted: Fri Dec 29, 2006 10:49 pm    Post subject: Reply with quote

erik258 wrote:
have you ever heard of crossdev?


Yes, I've successfully used it to bootstrap Gentoo onto an old Pentium 166 box when the 2006.1 install disks failed to boot on it. Also to compile MS-DOG and Win32 binaries on Linux.

I will cross compile a 64 bit version of GCC on my Ultra 2 and use that to build multilibs, then build GLIBC, then a 64 bit version of GCC, if only for the fun factor. By now most of the work in porting to the AMD64/ia64 platforms should be bearing fruit.
_________________
Cheers,
Alex.

Linux - the best text adventure game ever.
Back to top
View user's profile Send private message
erik258
Advocate
Advocate


Joined: 12 Apr 2005
Posts: 2650
Location: Twin Cities, Minnesota, USA

PostPosted: Fri Dec 29, 2006 10:56 pm    Post subject: Reply with quote

i think so, if i read you correctly. I run amd64. i won't ever have an itanium so i couldn't care less about ia64.
_________________
Configuring a Firewall? Try my iptables configuration
LinuxCommando.com is my blog for linux-related scraps and tidbits. Stop by for a visit!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo on Sparc All times are GMT
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