* ld error
@ 2002-05-27 7:19 G Anna
2002-05-27 18:27 ` Alfred Cleve
0 siblings, 1 reply; 8+ messages in thread
From: G Anna @ 2002-05-27 7:19 UTC (permalink / raw)
To: linux-assembly
Dear All,
I am working through 'Linux Assembly "Hello World" Tutorial, CS 200'
by Bjorn Chambless. But I am unable to compile the program given in
that. Kindly help me.
For your convenience I have included the assembly program at the end
of this mail.
average.s is the relevant assembly program file.
$ as -a --gstabs -o average.o average.s
$ ld -m elf_i386 -static /usr/lib/crt1.o /usr/lib/crti.o -lc average.o
/usr/lib/crtn.o
/usr/lib/libc.a(strtoll.o): In function `__strtoll_internal':
/usr/src/bs/BUILD/glibc-2.2.2/stdlib/../sysdeps/generic/strtol.c:386: undefined reference to `__udivdi3'
/usr/src/bs/BUILD/glibc-2.2.2/stdlib/../sysdeps/generic/strtol.c:387: undefined reference to `__umoddi3'
/usr/lib/libc.a(strtoull.o): In function `__strtoull_internal':
/usr/src/bs/BUILD/glibc-2.2.2/stdlib/../sysdeps/generic/strtol.c:386: undefined reference to `__udivdi3'
/usr/src/bs/BUILD/glibc-2.2.2/stdlib/../sysdeps/generic/strtol.c:387: undefined reference to `__umoddi3'
$ cat average.s
.data
.type hi_temp,@object
.size hi_temp,1
hi_temp:
.byte 0x92
.type lo_temp,@object
.size lo_temp,1
lo_temp:
.byte 0x52
.type av_temp,@object
.size av_temp,1
av_temp:
.byte 0
.text
.align 4
.globl main
.type main,@function
main:
pushl %ebp
movl %esp,%ebp
movb hi_temp,%al
addb lo_temp,%al
movb $0,%ah
adcb $0,%ah
movb $2,%bl
idivb %bl
movb %al,av_temp
leave
ret
$ as --version
GNU assembler 2.10.91
Copyright 2001 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License. This program has absolutely no warranty.
This assembler was configured for a target of `i386-redhat-linux'.
$ ld --version
GNU ld 2.10.91
Copyright 2001 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License. This program has absolutely no warranty.
Supported emulations:
elf_i386
i386linux
elf_i386_glibc21
$ gcc --version
2.96
$ uname -a
Linux wobble 2.4.16 #8 Tue May 14 14:15:58 IST 2002 i686 unknown
$ cat /etc/issue
Red Hat Linux release 7.1 (Seawolf)
Kernel 2.4.16 on an i686
Hope somebody will help me with this.
Thank you.
Cheers,
anna
--
(15) I will never employ any device with a digital countdown. If I find
that such a device is absolutely unavoidable, I will set it to
activate when the counter reaches 117 and the hero is just putting
his plan into operation. - Peter Anspach in "The Top 100 Things
I'd Do If I Ever Became An Evil Overlord"
http://www.eviloverlord.com
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: ld error
2002-05-27 7:19 ld error G Anna
@ 2002-05-27 18:27 ` Alfred Cleve
2002-05-28 5:27 ` G Anna
0 siblings, 1 reply; 8+ messages in thread
From: Alfred Cleve @ 2002-05-27 18:27 UTC (permalink / raw)
To: linux-assembly
Hi,
> I am working through 'Linux Assembly "Hello World" Tutorial, CS 200'
> by Bjorn Chambless. But I am unable to compile the program given in
> that. Kindly help me.
i suspect that exercise isn't a simple "hello world"-program. It seems to me
as a nasty trap for lazy students :-))
The module "average" is a subroutine e.g. a "function" which should be linked
to a given C-Program.
For my first step i'm looking for a readable tutorial to the "gas"-assembler.
Have you seen anything in the web ?
Thanks,
Alfred
--
Alfred Cleve
Karbener Str. 7
61130 Nidderau-Heldenbergen
Germany
Phone +49-6187-901095
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: ld error
2002-05-27 18:27 ` Alfred Cleve
@ 2002-05-28 5:27 ` G Anna
2002-05-28 11:26 ` Brian Raiter
2002-05-28 12:54 ` J.S.Souza
0 siblings, 2 replies; 8+ messages in thread
From: G Anna @ 2002-05-28 5:27 UTC (permalink / raw)
To: Alfred Cleve; +Cc: linux-assembly
> Date: Mon, 27 May 2002 20:27:52 +0200
> From: Alfred.Cleve@t-online.de (Alfred Cleve)
> Subj: Re: ld error
>
> Hi,
>
> > I am working through 'Linux Assembly "Hello World" Tutorial, CS 200'
> > by Bjorn Chambless. But I am unable to compile the program given in
> > that. Kindly help me.
>
> i suspect that exercise isn't a simple "hello world"-program. It
> seems to me as a nasty trap for lazy students :-))
>
> The module "average" is a subroutine e.g. a "function" which should
> be linked to a given C-Program.
I don't think so, because the given assembly program has a main
function; and the tutorial has given a step by step procedure to
produce the executable.
Inspite of my above statement, I am not very sure of the given
assembly program being complete, basically because it doesn't work!
But it does have a main function.
[ Added as an after-thought: Doesn't the function named 'main' have
any special significance in assembly language programs? ]
(begin-quote)
/* segment registers set up by linked code */
/* beginning of text(code) segment */
.text
.align 4 /* set 4 double-word alignment */
.globl main /* make main global for linker */
.type main,@function /* declare main as a function */
main:
(definition of main snipped)
(end-quote)
If what you say is correct, then I don't think the tutorial serves its
purpose. Already, I am pulling my hairs to understand what is going
on, and now I have got to put up with the caveats that the author
thought to be educational. (No offence meant to the author, its just
my critique of the tutorial.)
> For my first step i'm looking for a readable tutorial to the
> "gas"-assembler.
Simply start from http://www.linuxassembly.org
Cheers,
anna
--
(15) I will never employ any device with a digital countdown. If I find
that such a device is absolutely unavoidable, I will set it to
activate when the counter reaches 117 and the hero is just putting
his plan into operation. - Peter Anspach in "The Top 100 Things
I'd Do If I Ever Became An Evil Overlord"
http://www.eviloverlord.com
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: ld error
2002-05-28 5:27 ` G Anna
@ 2002-05-28 11:26 ` Brian Raiter
2002-05-28 14:32 ` Robert Plantz
2002-05-28 12:54 ` J.S.Souza
1 sibling, 1 reply; 8+ messages in thread
From: Brian Raiter @ 2002-05-28 11:26 UTC (permalink / raw)
To: linux-assembly; +Cc: Alfred Cleve
> I don't think so, because the given assembly program has a main
> function; and the tutorial has given a step by step procedure to
> produce the executable.
>
> Inspite of my above statement, I am not very sure of the given
> assembly program being complete, basically because it doesn't work!
> But it does have a main function.
Instead of having to build the link line yourself, you could just let
gcc do it for you. That is, instead of:
ld -m elf_i386 -static average.o /usr/lib/crtn.o /foo/bar/baz blahblahblah
use:
gcc -static average.o
b
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: ld error
2002-05-28 11:26 ` Brian Raiter
@ 2002-05-28 14:32 ` Robert Plantz
0 siblings, 0 replies; 8+ messages in thread
From: Robert Plantz @ 2002-05-28 14:32 UTC (permalink / raw)
To: linux-assembly
On Tuesday, May 28, 2002, at 04:26 AM, Brian Raiter wrote:
>> I don't think so, because the given assembly program has a main
>> function; and the tutorial has given a step by step procedure to
>> produce the executable.
>>
>> Inspite of my above statement, I am not very sure of the given
>> assembly program being complete, basically because it doesn't work!
>> But it does have a main function.
>
> Instead of having to build the link line yourself, you could just let
> gcc do it for you. That is, instead of:
>
> ld -m elf_i386 -static average.o /usr/lib/crtn.o /foo/bar/baz
> blahblahblah
>
> use:
>
> gcc -static average.o
I use gas for teaching assembly language. I have my students simply
use
gcc average.o -o average
Then they can use C library functions to do I/O. For example, I
have them use read() and write() to interact with the terminal. By
restricting them to read/write one byte at a time, I can give
several interesting assignments to help them learn how fundamental
C programming constructs are implemented at the assembly language
level. (Well, how they *could* be implemented; compilers
sometimes do silly things.)
>
> b
> -
> To unsubscribe from this list: send the line "unsubscribe
> linux-assembly" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
-------------------------------------------------------
Robert G. Plantz, PhD |
Professor of Computer Science | cs.sonoma.edu/~bob
Sonoma State University | plantz@sonoma.edu
1801 E. Cotati Ave. | ph: 707.664.2806
Rohnert Park, CA 94928 | fax: 707.664.3012
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: ld error
2002-05-28 5:27 ` G Anna
2002-05-28 11:26 ` Brian Raiter
@ 2002-05-28 12:54 ` J.S.Souza
1 sibling, 0 replies; 8+ messages in thread
From: J.S.Souza @ 2002-05-28 12:54 UTC (permalink / raw)
To: linux-assembly
No, "main" doesn't have any special significance in assembly and is NOT
required. However, the assembler _does_ look for a procedure named "_start",
but this also is not required because it will default to something else and
just give you a warning about it if it's not included. BTW, I understand how
you feel about pulling your hair out, but this is the best way to learn _any_
language. Also, all you really need to do to assemble and link a program is
the following:
as -o hello.o hello
ld -o hello hello.o
All the other stuff is just extra. I usually assembly my programs with
--gstabs so that I can debug them with gdb, but it's not necessary for the
program to assemble. --gstabs is the same as the -g when compiling C
programs.
Cheers,
Jeff Souza
On Monday 27 May 2002 10:27 pm, G Anna wrote:
> > Date: Mon, 27 May 2002 20:27:52 +0200
> > From: Alfred.Cleve@t-online.de (Alfred Cleve)
> > Subj: Re: ld error
> >
> > Hi,
> >
> > > I am working through 'Linux Assembly "Hello World" Tutorial, CS 200'
> > > by Bjorn Chambless. But I am unable to compile the program given in
> > > that. Kindly help me.
> >
> > i suspect that exercise isn't a simple "hello world"-program. It
> > seems to me as a nasty trap for lazy students :-))
> >
> > The module "average" is a subroutine e.g. a "function" which should
> > be linked to a given C-Program.
>
> I don't think so, because the given assembly program has a main
> function; and the tutorial has given a step by step procedure to
> produce the executable.
>
> Inspite of my above statement, I am not very sure of the given
> assembly program being complete, basically because it doesn't work!
> But it does have a main function.
>
> [ Added as an after-thought: Doesn't the function named 'main' have
> any special significance in assembly language programs? ]
>
> (begin-quote)
>
> /* segment registers set up by linked code */
> /* beginning of text(code) segment */
> .text
> .align 4 /* set 4 double-word alignment */
> .globl main /* make main global for linker */
> .type main,@function /* declare main as a function */
> main:
> (definition of main snipped)
>
> (end-quote)
>
> If what you say is correct, then I don't think the tutorial serves its
> purpose. Already, I am pulling my hairs to understand what is going
> on, and now I have got to put up with the caveats that the author
> thought to be educational. (No offence meant to the author, its just
> my critique of the tutorial.)
>
> > For my first step i'm looking for a readable tutorial to the
> > "gas"-assembler.
>
> Simply start from http://www.linuxassembly.org
>
> Cheers,
> anna
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: ld error
@ 2002-05-27 18:58 Emmet Ford
2002-05-28 1:51 ` Brian Raiter
0 siblings, 1 reply; 8+ messages in thread
From: Emmet Ford @ 2002-05-27 18:58 UTC (permalink / raw)
To: linux-assembly
> a readable tutorial to the "gas"-assembler.
You wander along a lightly trodden path. Here is what I have...
Linux Assembly Tutorial (nice)
http://www.geocities.com/SiliconValley/Ridge/2544/asm/linux-asm.txt
Using Assembly Language in Linux
http://linuxassembly.org/linasm.html
int80h.org -- Unix Assembly Language Programming
http://www.int80h.org/
http://www.gnu.org/manual/gas-2.9.1/as.html
Using as - Table of Contents - GNU Project - Free Software Foundation (FSF)
A Whirlwind Tutorial on Creating Really Teensy ELF Executables for Linux
http://members.tripod.de/linux_progz/docs/teensy.html
Linux 4k intro page
http://ma.verick.co.za/linux4k/
--Emmet Ford
-------- Original Message --------
Subject: Re: ld error
Date: Mon, 27 May 2002 20:27:52 +0200
From: Alfred.Cleve@t-online.de (Alfred Cleve)
To: linux-assembly@vger.kernel.org
References: <m3r8jygir3.fsf@wobble.eth.net>
Hi,
> I am working through 'Linux Assembly "Hello World" Tutorial, CS 200'
> by Bjorn Chambless. But I am unable to compile the program given in
> that. Kindly help me.
i suspect that exercise isn't a simple "hello world"-program. It seems
to me
as a nasty trap for lazy students :-))
The module "average" is a subroutine e.g. a "function" which should be
linked
to a given C-Program.
For my first step i'm looking for a readable tutorial to the
"gas"-assembler.
Have you seen anything in the web ?
Thanks,
Alfred
--
Alfred Cleve
Karbener Str. 7
61130 Nidderau-Heldenbergen
Germany
Phone +49-6187-901095
-
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2002-05-28 14:32 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-05-27 7:19 ld error G Anna
2002-05-27 18:27 ` Alfred Cleve
2002-05-28 5:27 ` G Anna
2002-05-28 11:26 ` Brian Raiter
2002-05-28 14:32 ` Robert Plantz
2002-05-28 12:54 ` J.S.Souza
-- strict thread matches above, loose matches on Subject: below --
2002-05-27 18:58 Emmet Ford
2002-05-28 1:51 ` Brian Raiter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).