* What changed in ld?
@ 2001-06-01 10:50 G. Adam Stanislav
2001-06-01 10:57 ` H . J . Lu
2001-06-01 11:25 ` Philip Blundell
0 siblings, 2 replies; 10+ messages in thread
From: G. Adam Stanislav @ 2001-06-01 10:50 UTC (permalink / raw)
To: binutils
Hello, I posted this in the FreeBSD hackers list and was referred
to you. I was told that when I upgraded to FreeBSD 4.3, I also
upgraded binutils from 2.9.1 to 2.10.1.
I am the author of the assembly language tutorial for FreeBSD
( http://www.int80h.org/bsdasm/ ), but something has changed in ld
that causes programs assembled with nasm 0.98 and linked with ld
crash with the bus error when having uninitialized data in the
.bss section. This worked with no problems with ld from binutils
2.9.1.
My original message follows. Please advise (I am not subscribed
to this list, so please CC your advice to me). Thank you,
Adam
>Delivered-To: whizkid-whizkidtech:net-adam@whizkidtech.net
>X-Envelope-To: adam@whizkidtech.net
>Delivered-To: freebsd-hackers@freebsd.org
>Date: Fri, 1 Jun 2001 02:42:34 -0500
>From: "G. Adam Stanislav" <adam@whizkidtech.net>
>To: hackers@FreeBSD.org
>Subject: What changed in ld?
>X-Mailer: Mutt 1.0.1i
>Organization: Whiz Kid Technomagic
>X-Assembly-Language: http://int80h.org/
>X-Web-Search: http://phonecowboy.master.com/
>X-Operating-System: FreeBSD whizkidtech.net 4.3-20010525-STABLE FreeBSD
4.3-20010525-STABLE
>Sender: owner-freebsd-hackers@FreeBSD.ORG
>List-ID: <freebsd-hackers.FreeBSD.ORG>
>List-Archive: < http://docs.freebsd.org/mail/ > (Web Archive)
>List-Help: < mailto:majordomo?subject=help > (List Instructions)
>List-Subscribe: < mailto:majordomo?subject=subscribe%20freebsd-hackers >
>List-Unsubscribe: < mailto:majordomo?subject=unsubscribe%20freebsd-hackers >
>X-Loop: FreeBSD.ORG
>
>I have recently upgraded from FreeBSD 3.1 to 4.3-20010525-STABLE.
>
>I wrote a very simple assembly language program that was giving me
>a bus error. For several hours I have been trying to find what was
>wrong with it, but could not.
>
>Finally, out of desperation, I moved uninitialized data from .bss
>to .data, and suddenly the program worked without a problem.
>
>This puzzled me, so I used ld on an older program of mine, one of
>the programs from my assembly language tutorial
>( http://www.int80h.org/bsdasm/ ). It started giving me the same
>bus errors. The version I created under 3.1 continues to work
>fine.
>
>That tells me something has changed in the way ld handles the .bss
>section between 3.1 and 4.3 - either on purpose or as a bug.
>This completely invalidates my assembly language tutorial. If the
>change was on purpose, can someone please tell me what new switch
>I need to use with ld to recognize the .bss section as being bss?
>
>Thank you,
>Adam
>--
>Perfection is for neurotics
>
>
>To Unsubscribe: send mail to majordomo@FreeBSD.org
>with "unsubscribe freebsd-hackers" in the body of the message
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: What changed in ld?
2001-06-01 10:50 What changed in ld? G. Adam Stanislav
@ 2001-06-01 10:57 ` H . J . Lu
2001-06-01 11:36 ` G. Adam Stanislav
2001-06-01 11:25 ` Philip Blundell
1 sibling, 1 reply; 10+ messages in thread
From: H . J . Lu @ 2001-06-01 10:57 UTC (permalink / raw)
To: G. Adam Stanislav; +Cc: binutils
On Fri, Jun 01, 2001 at 12:50:28PM -0500, G. Adam Stanislav wrote:
> Hello, I posted this in the FreeBSD hackers list and was referred
> to you. I was told that when I upgraded to FreeBSD 4.3, I also
> upgraded binutils from 2.9.1 to 2.10.1.
>
> I am the author of the assembly language tutorial for FreeBSD
> ( http://www.int80h.org/bsdasm/ ), but something has changed in ld
> that causes programs assembled with nasm 0.98 and linked with ld
Are you using ELF? nasm usually generates bad ELF object files.
H.J.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: What changed in ld?
2001-06-01 10:50 What changed in ld? G. Adam Stanislav
2001-06-01 10:57 ` H . J . Lu
@ 2001-06-01 11:25 ` Philip Blundell
2001-06-01 11:37 ` G. Adam Stanislav
1 sibling, 1 reply; 10+ messages in thread
From: Philip Blundell @ 2001-06-01 11:25 UTC (permalink / raw)
To: G. Adam Stanislav; +Cc: binutils
>>That tells me something has changed in the way ld handles the .bss
>>section between 3.1 and 4.3 - either on purpose or as a bug.
>>This completely invalidates my assembly language tutorial. If the
>>change was on purpose, can someone please tell me what new switch
>>I need to use with ld to recognize the .bss section as being bss?
This question is rather broad. I think you will need to provide a testcase
and explain what you think is wrong about the new behaviour.
p.
--
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.5 (GNU/Linux)
Comment: Exmh version 2.1.1 10/15/1999 (debian)
iD8DBQE7F936VTLPJe9CT30RAnl0AKDLoe01xAbmAXDLfp/bBr8c4/XYXACbB1yk
OQKO2/+vvOLIsezOJKYtjKs=
=lwBG
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: What changed in ld?
2001-06-01 10:57 ` H . J . Lu
@ 2001-06-01 11:36 ` G. Adam Stanislav
2001-06-01 11:44 ` H . J . Lu
2001-06-01 11:49 ` Andrew Haley
0 siblings, 2 replies; 10+ messages in thread
From: G. Adam Stanislav @ 2001-06-01 11:36 UTC (permalink / raw)
To: H . J . Lu; +Cc: binutils
At 10:57 01-06-2001 -0700, H . J . Lu wrote:
>On Fri, Jun 01, 2001 at 12:50:28PM -0500, G. Adam Stanislav wrote:
>> Hello, I posted this in the FreeBSD hackers list and was referred
>> to you. I was told that when I upgraded to FreeBSD 4.3, I also
>> upgraded binutils from 2.9.1 to 2.10.1.
>>
>> I am the author of the assembly language tutorial for FreeBSD
>> ( http://www.int80h.org/bsdasm/ ), but something has changed in ld
>> that causes programs assembled with nasm 0.98 and linked with ld
>
>Are you using ELF? nasm usually generates bad ELF object files.
Yes, I'm using elf. But I did not have any problem when using the ld
from binutils 2.9.1. I was using the same version of nasm.
What can I do?
Adam
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: What changed in ld?
2001-06-01 11:25 ` Philip Blundell
@ 2001-06-01 11:37 ` G. Adam Stanislav
2001-06-01 11:57 ` Philip Blundell
0 siblings, 1 reply; 10+ messages in thread
From: G. Adam Stanislav @ 2001-06-01 11:37 UTC (permalink / raw)
To: Philip Blundell; +Cc: binutils
At 19:24 01-06-2001 +0100, Philip Blundell wrote:
>>>That tells me something has changed in the way ld handles the .bss
>>>section between 3.1 and 4.3 - either on purpose or as a bug.
>>>This completely invalidates my assembly language tutorial. If the
>>>change was on purpose, can someone please tell me what new switch
>>>I need to use with ld to recognize the .bss section as being bss?
>
>This question is rather broad. I think you will need to provide a testcase
>and explain what you think is wrong about the new behaviour.
Very well. Here is some example code that performed flawlessly
before, but causes a bus error whenever the "write" procedure
is called. If I comment out the "section .bss" directive, it
works, but wastes disk space as it allocates the buffers in the
.data section instead of just reserving it in the .bss section:
%include 'system.inc'
%define BUFSIZE 2048
section .data
fd.in dd
stdin
fd.out dd stdout
section .bss
ibuffer resb BUFSIZE
obuffer resb
BUFSIZE
section .code
[...]
read:
push dword BUFSIZE
mov esi, ibuffer
push esi
push dword [fd.in]
sys.read
add esp, byte 12
mov ebx, eax
or
eax, eax
je .done
sub eax, eax
ret
align 4
.done:
call write ; flush
output buffer
[...]
align 4
write:
sub edi, ecx ; start of buffer
push
ecx
push edi
push dword [fd.out]
sys.write
add esp, byte 12
sub eax,
eax
sub ecx, ecx ; buffer is empty now
ret
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: What changed in ld?
2001-06-01 11:36 ` G. Adam Stanislav
@ 2001-06-01 11:44 ` H . J . Lu
2001-06-01 11:49 ` Andrew Haley
1 sibling, 0 replies; 10+ messages in thread
From: H . J . Lu @ 2001-06-01 11:44 UTC (permalink / raw)
To: G. Adam Stanislav; +Cc: binutils
On Fri, Jun 01, 2001 at 01:28:12PM -0500, G. Adam Stanislav wrote:
> >
> >Are you using ELF? nasm usually generates bad ELF object files.
>
> Yes, I'm using elf. But I did not have any problem when using the ld
> from binutils 2.9.1. I was using the same version of nasm.
>
> What can I do?
If you can provide a testcase which I can use under Linux, I will
take a look.
H.J.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: What changed in ld?
2001-06-01 11:36 ` G. Adam Stanislav
2001-06-01 11:44 ` H . J . Lu
@ 2001-06-01 11:49 ` Andrew Haley
2001-06-01 12:02 ` H . J . Lu
1 sibling, 1 reply; 10+ messages in thread
From: Andrew Haley @ 2001-06-01 11:49 UTC (permalink / raw)
To: G. Adam Stanislav; +Cc: H . J . Lu, binutils
G. Adam Stanislav writes:
> At 10:57 01-06-2001 -0700, H . J . Lu wrote:
> >On Fri, Jun 01, 2001 at 12:50:28PM -0500, G. Adam Stanislav wrote:
> >> Hello, I posted this in the FreeBSD hackers list and was referred
> >> to you. I was told that when I upgraded to FreeBSD 4.3, I also
> >> upgraded binutils from 2.9.1 to 2.10.1.
> >>
> >> I am the author of the assembly language tutorial for FreeBSD
> >> ( http://www.int80h.org/bsdasm/ ), but something has changed in ld
> >> that causes programs assembled with nasm 0.98 and linked with ld
> >
> >Are you using ELF? nasm usually generates bad ELF object files.
>
> Yes, I'm using elf. But I did not have any problem when using the ld
> from binutils 2.9.1. I was using the same version of nasm.
Read the NASM page. It says:
http://www.web-sites.co.uk/nasm/bugs.html
"Relocations between multiple code segments in ELF are wrong. NASM's
ELF files don't conform to the ELF standard properly. "
> What can I do?
I would have thought it would be a good time to fix nasm.
Andrew.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: What changed in ld?
2001-06-01 11:37 ` G. Adam Stanislav
@ 2001-06-01 11:57 ` Philip Blundell
0 siblings, 0 replies; 10+ messages in thread
From: Philip Blundell @ 2001-06-01 11:57 UTC (permalink / raw)
To: G. Adam Stanislav; +Cc: binutils
>Very well. Here is some example code that performed flawlessly
>before, but causes a bus error whenever the "write" procedure
>is called. If I comment out the "section .bss" directive, it
>works, but wastes disk space as it allocates the buffers in the
>.data section instead of just reserving it in the .bss section:
Thanks, but a test in this form is not much use to me; I don't run FreeBSD,
and I don't have nasm. For linker bugs you really need to provide an object
file, the output generated by the linker, and a detailed explanation of what
is wrong with the latter (e.g. "the destination for the CALL instruction at
0x666 is incorrect", or "the .frobozz section is missing from the output
file"). Simply reporting that your program crashes is not especially useful
since that might be caused by bugs in your code, or in the assembler you are
using, or in some library.
p.
--
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.5 (GNU/Linux)
Comment: Exmh version 2.1.1 10/15/1999 (debian)
iD8DBQE7F+WnVTLPJe9CT30RAj5kAKDLdGGgeETuzFX0k1YlRnP1ujlTTACdEzT6
eaIDX9CAxPH8RRwtxmDfEVA=
=HHbs
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: What changed in ld?
2001-06-01 11:49 ` Andrew Haley
@ 2001-06-01 12:02 ` H . J . Lu
2001-06-01 12:38 ` G. Adam Stanislav
0 siblings, 1 reply; 10+ messages in thread
From: H . J . Lu @ 2001-06-01 12:02 UTC (permalink / raw)
To: Andrew Haley; +Cc: G. Adam Stanislav, binutils
On Fri, Jun 01, 2001 at 07:49:21PM +0100, Andrew Haley wrote:
>
> Read the NASM page. It says:
>
> http://www.web-sites.co.uk/nasm/bugs.html
>
> "Relocations between multiple code segments in ELF are wrong. NASM's
> ELF files don't conform to the ELF standard properly. "
>
> > What can I do?
>
> I would have thought it would be a good time to fix nasm.
FWIW, I have fixed all the nasm ELF bugs which I can reproduce.
H.J.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: What changed in ld?
2001-06-01 12:02 ` H . J . Lu
@ 2001-06-01 12:38 ` G. Adam Stanislav
0 siblings, 0 replies; 10+ messages in thread
From: G. Adam Stanislav @ 2001-06-01 12:38 UTC (permalink / raw)
To: H . J . Lu, Andrew Haley; +Cc: binutils
At 12:02 01-06-2001 -0700, H . J . Lu wrote:
>> > What can I do?
>>
>> I would have thought it would be a good time to fix nasm.
>
>FWIW, I have fixed all the nasm ELF bugs which I can reproduce.
Thank you, everybody. I found the problem and fixed it:
The messages here that mentioned there was something non-standard
in nasm reminded me there was something non-standard in my code:
Instead of using .text I was using .code. This worked fine before.
But it was non-standard. I have now changed it to .text, and suddenly
everything works fine again.
I had not thought of it until I saw your messages: So I do have you
to thank for solving this mystery.
Cheers,
Adam
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2001-06-01 12:38 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-01 10:50 What changed in ld? G. Adam Stanislav
2001-06-01 10:57 ` H . J . Lu
2001-06-01 11:36 ` G. Adam Stanislav
2001-06-01 11:44 ` H . J . Lu
2001-06-01 11:49 ` Andrew Haley
2001-06-01 12:02 ` H . J . Lu
2001-06-01 12:38 ` G. Adam Stanislav
2001-06-01 11:25 ` Philip Blundell
2001-06-01 11:37 ` G. Adam Stanislav
2001-06-01 11:57 ` Philip Blundell
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 read-only IMAP folder(s) and NNTP newsgroup(s).