This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: What changed in ld?


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]