[Nasm-bugs] [Bug 3392807] New: nasm generates SHT_RELA debug sections on i686. Should be SHT_REL.

noreply-nasm at dev.nasm.us noreply-nasm at dev.nasm.us
Tue Aug 30 21:56:53 PDT 2022


https://bugzilla.nasm.us/show_bug.cgi?id=3392807

            Bug ID: 3392807
           Summary: nasm generates SHT_RELA debug sections on i686. Should
                    be SHT_REL.
           Product: NASM
           Version: 2.15.xx
          Hardware: All
                OS: All
            Status: OPEN
          Severity: normal
          Priority: Medium
         Component: Assembler
          Assignee: nobody at nasm.us
          Reporter: pierre.labastie at neuf.fr
                CC: chang.seok.bae at intel.com, gorcunov at gmail.com,
                    hpa at zytor.com, nasm-bugs at nasm.us
     Obtained from: Build from source archive using configure

Here is a small program as an example (all the commands were run in an i686
VM):

$ cat hello.asm
   ; Simple NASM syntax assembly program for x86 (32 bit).
   ;
   extern printf
   global main
   section .text
   main:
   push ebp
   mov ebp, esp
   push msg
   call printf
   add esp, 4
   leave
   ret
   section .data
   msg db 'Hello, world!', 13, 10, 0

Assemble with debug information:

$ nasm -f elf32 -F dwarf hello.asm

Link with gold:
$ gcc -o hello-gold -fuse-ld=gold hello.o
/usr/bin/ld.gold: internal error in relocate_section, at
../../gold/i386.cc:3683
collect2: error: ld returned 1 exit status

The error at i386.cc is an assert about the section being SHT_REL. According to
the binutils devs, SHT_RELA shouldn't be used on i686
(https://sourceware.org/pipermail/binutils/2022-August/122671.html).

Note that ld.bfd seems to accept those (an unrelated warning is generated
though):

$ gcc -o hello hello.o
/usr/bin/ld: warning: hello.o: missing .note.GNU-stack section implies
executable stack
/usr/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future
version of the linker
$ ./hello
Hello, world!

I've looked at the source of output/outelf.c: it is easy to change the lines
around 2006 and ff to generate SHT_REL section headers, but I couldn't figure
out how to properly generate the sections themselves.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are watching all bug changes.


More information about the Nasm-bugs mailing list