Assembler elf-Format Problem

üäpöol

Erfahrenes Mitglied
Hi,

ich habe ein Problem mit dem elf-Format.
Hier mein Code.

Code:
start:
	mov si, msg
	call schreiben
	call lesen
	mov ah, 0x04C
	int 0x21

schreiben:
	lodsb
	or al, al
	jz _ret
	mov bx, 0x07
	mov ah, 0x0E
	int 0x10
	jmp schreiben
	
lesen:
	mov ah, 0x0
	int 0x16
	ret
	
_ret:
	retn

msg db "Teststring", 13, 10, 0

Das assembliere ich mit "nasm -f elf -o test.elf test.asm".
Soweit kein Problem.

Ich muss die Datei aber linken.
Also "ld.exe -T link.ld -o test.bin test.elf".
Jetzt bekomme ich folgende Fehlermeldung: "(.text+0x2): relocation truncated to fit: R_386_16 against `.text'".
Das Problem ist wohl das mov si, msg.

Was ist der Unterschied zwischen elf und z.B. bin?

Danke im Voraus.
 
Also elf ist ein Executable-Format, das Standard-Format unter aktuellen Linux-Derivaten. .bin ist jetzt erstmal eine Erweiterung und sagt nichts darüber aus, was für ein Executable-Format sich dahinter verbirgt. Das Linker-Script wäre interessant.
 
Hi.

Code:
OUTPUT_FORMAT("binary")
ENTRY(start)
phys = 0x00100000;
SECTIONS
{
  .text phys : AT(phys) {
    code = .;
    *(.text)
    *(.rodata)
    . = ALIGN(4096);
  }
  .data : AT(phys + (data - code))
  {
    data = .;
    *(.data)
    . = ALIGN(4096);
  }
  .bss : AT(phys + (bss - code))
  {
    bss = .;
    *(.bss)
    . = ALIGN(4096);
  }
  end = .;
}
 
Zurück