[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug binutils/13616] New: linker should pad executable sections with nop

From: roland at gnu dot org
Subject: [Bug binutils/13616] New: linker should pad executable sections with nops, not zeros
Date: Mon, 23 Jan 2012 19:20:58 +0000


             Bug #: 13616
           Summary: linker should pad executable sections with nops, not
           Product: binutils
           Version: 2.23 (HEAD)
            Status: NEW
          Severity: normal
          Priority: P2
         Component: binutils
        AssignedTo: address@hidden
        ReportedBy: address@hidden
    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
    $ ./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
    $ 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.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]