bug-binutils
[Top][All Lists]
Advanced

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

[Bug gas/29145] GAS always generates padding instructions regardless of


From: nickc at redhat dot com
Subject: [Bug gas/29145] GAS always generates padding instructions regardless of `--no-pad-sections`
Date: Wed, 18 May 2022 16:13:59 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=29145

Nick Clifton <nickc at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nickc at redhat dot com

--- Comment #1 from Nick Clifton <nickc at redhat dot com> ---
(In reply to LIU Hao from comment #0)

> We attempt to compile the same code targeting mingw-w64:

> This time the `.text` section has a size of 16 and alignment of 16 bytes,
> which is undesired.

Unfortunately this is required by the PE specification, so it cannot
be changed.  (The alignment of the .text section can be increased, but
it cannot be decreased below 16 bytes).

> This also results in extra NOPs in the object file:

True - but it is not quite as bad as you might assume.  If you have a
second function in your test file, it will take up some/all of these
bytes, thus potentially reducing the number of NOPs.  For example:

  % cat test2.s
        .text
        .globl  bar
        .def    bar; .scl 2; .type 32; .endef
        .seh_proc       bar
bar:
        .seh_endprologue
        jmp     foo
        .seh_endproc

        .globl  barf
        .def    barf; .scl 2; .type 32; .endef
        .seh_proc       barf
barf:
        .seh_endprologue
        jmp     foo
        .seh_endproc

        .def    foo; .scl 2; .type 32; .endef

  % as test2.s -o test2.o
  % objdump -d test2.o

  Disassembly of section .text:

  0000000000000000 <bar>:
     0: e9 00 00 00 00          jmp    5 <barf>

  0000000000000005 <barf>:
     5: e9 00 00 00 00          jmp    a <barf+0x5>
     a: 90                      nop
     b: 90                      nop
     c: 90                      nop
     d: 90                      nop
     e: 90                      nop
     f: 90                      nop

So this version of the test case only has 6 nop instructions in it...

-- 
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]