Menu

ELF compilation problem

2009-09-27
2013-04-20
  • Nobody/Anonymous

    Hi

    I want to compile the code below. If I choose '-bin' everything is ok. But when I choose elf (I want to link with some other objects), I got the following error messages:

    ELF:
    file.asm(1) : Error A2121: Symbol not defined : DGROUP

    ELF64:
    file.asm(1) : Warning A4114: Multiple .MODEL directives, .MODEL ignored

      .MODEL TINY

      .CODE

      .486

      ORG 7C00h

    start:

      add ax, WORD PTR

      SomeData DD 0

      ORG 7C00h+200h

      END start

     
  • Nobody/Anonymous

    If I use FLAT model this disappers. However, I still have a problem after compilation:

    **file.o: file not recognized: File format not recognize**

     
  • Nobody/Anonymous

    Using .MODEL TINY creates group DGROUP. If you want to avoid this, remove the .MODEL directive and use full segment directives:


    .486

    _TEXT16 segment WORD use16 public 'CODE'

    ORG 7C00h

    start:

    add ax, WORD PTR

    SomeData DD 0

    ORG 7C00h+200h

    _TEXT16 ends

    END start

    However, the ORG 7C00h tells me that you want some "bootloader" code. I doubt that ELF is the best format then. It might be better to use BIN and include the resulting binary data into the other object with directive INCBIN.

    japheth

     
  • Nobody/Anonymous

    Thank you, japheth.

    However, still the question is: why the compiled elf object is broken? I use latest 2.0 version. During compilation I am warned that GNU extensions for 8/16 bit relocations are used. But the resulting object is broken. Midnight commander says it has a "corrupted header" and ld doesn't want to link it with anything.

     
  • Nobody/Anonymous

    I  just tried to link your sample with LD. It tells:

    TEST.ASM:(_TEXT16+0x7c03): relocation truncated to fit: R_386_16

    IIRC this warning is ok and to be ignored.

    I also tried to view the elf-header with a tool (htwin32), and this tool indeed doesn't know the 16-bit relocation used. But besides this issue there is no problem reported.

    japheth

     

Log in to post a comment.