http://sourceware.org/bugzilla/show_bug.cgi?id=13616

             Bug #: 13616
           Summary: linker should pad executable sections with nops, not
                    zeros
           Product: binutils
           Version: 2.23 (HEAD)
            Status: NEW
          Severity: normal
          Priority: P2
         Component: binutils
        AssignedTo: unassig...@sourceware.org
        ReportedBy: rol...@gnu.org
    Classification: Unclassified


When an output section requires alignment padding between input sections,
and the input sections are executable (SHF_EXECINSTR/SEC_CODE), the linker
should use nop instructions to pad rather than zeros.  For known named
sections mentioned in the linker script, this is accomplished using the
=FILL syntax in the script.  But that doesn't input cover sections not
mentioned at all in the linker script.

Here is an example:

    $ cat foo.s
    .section code1,"ax",@progbits
    .align 32
        ret
    $ ./gas/as-new -o foo.o foo.s
    $ ./ld/ld-new -o foo foo.o foo.o
    ./ld/ld-new: warning: cannot find entry symbol _start; defaulting to
0000000000400078
    $ objdump -rd foo

    foo:     file format elf64-x86-64


    Disassembly of section code1:

    0000000000400080 <code1>:
      400080:    c3                       retq   
        ...
      40009d:    00 00                    add    %al,(%rax)
      40009f:    00 c3                    add    %al,%bl
    $

There is a similar problem with two differently-named sections that become
contiguous in the output file.  But that case is not readily displayed by
objdump, which omits the intersection bytes altogether.

Note that gold almost gets this right.  It uses nops for the padding.  But
in this particular case, instead of a long string of nop instructions, it
generates a jump around the gap, but leaves the rest of the gap filled with
zeros rather than valid instructions.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

_______________________________________________
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils

Reply via email to