Package: nasm
Severity: important
Version: 0.99.06-1
Tags: patch
User: [EMAIL PROTECTED]
Usertags: kfreebsd

Hello,

the nasm is currently unusable on GNU/kFreeBSD.

The nasm generates object files, which are not recognized
by current binutils on GNU/kFreeBSD.

The problem is that Linux and GNU/kFreeBSD ELF format
differs in OS/ABI field, i.e. "readelf -h /bin/bash"
should produce on Linux:

ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Intel 80386
  Version:                           0x1

and on GNU/kFreeBSD:

ELF Header:
  Magic:   7f 45 4c 46 01 01 01 09 00 00 00 00 00 00 00 00
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - FreeBSD
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Intel 80386
  Version:                           0x1


But the nasm produces everywhere "UNIX - System V"
and recent binutils started to check this.
Currently it prevents building of libsdl1.2 for kfreebsd-i386.

Please, could you apply attached patch to produce
"UNIX - FreeBSD" elf files on GNU/kFreeBSD.

It would also be nice if you can inform upstream
about this issue.

Thanks in advance

                        Petr
only in patch2:
unchanged:
--- nasm-0.99.06.orig/output/outelf32.c
+++ nasm-0.99.06/output/outelf32.c
@@ -1000,7 +1000,11 @@
     /*
      * Output the ELF header.
      */
+#ifdef __FreeBSD_kernel__
+    fwrite("\177ELF\1\1\1\11\0\0\0\0\0\0\0\0", 16, 1, elffp);
+#else    
     fwrite("\177ELF\1\1\1\0\0\0\0\0\0\0\0\0", 16, 1, elffp);
+#endif    
     fwriteint16_t(1, elffp);      /* ET_REL relocatable file */
     fwriteint16_t(3, elffp);      /* EM_386 processor ID */
     fwriteint32_t(1L, elffp);      /* EV_CURRENT file format version */
only in patch2:
unchanged:
--- nasm-0.99.06.orig/output/outelf64.c
+++ nasm-0.99.06/output/outelf64.c
@@ -1033,7 +1033,11 @@
     /*
      * Output the ELF header.
      */
+#ifdef __FreeBSD_kernel__
+    fwrite("\177ELF\2\1\1\11\0\0\0\0\0\0\0\0", 16, 1, elffp);
+#else    
     fwrite("\177ELF\2\1\1\0\0\0\0\0\0\0\0\0", 16, 1, elffp);
+#endif    
     fwriteint16_t(ET_REL, elffp);      /* relocatable file */
     fwriteint16_t(EM_X86_64, elffp);      /* processor ID */
     fwriteint32_t(1L, elffp);      /* EV_CURRENT file format version */

Reply via email to