This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC,GAS]Propose to emit the attribute section after relaxation

Hi there,

For targets like ARM, some architecture related attributes can only be
finalized after relaxation step due to relaxable instructions. By then the
attribute section is already emitted,  there is no chance to update the
emitted attribute section. At least I tried and couldn't find a way to do
so. In order to take into account the relaxation, I propose to emit
attribute section after relaxation step. The required changes are shown in
attached patch. I just refactored some functions and then call
create_obj_attrs_section function after relaxation step. Any comments are

The issue I mentioned happens when target isn't specified either via
assembly code like .arch/.cpu or via command line option. Here is a small

$ cat t.s
.syntax unified
        cmp     r0, r1
        beq     foo

$ ../build/gas/as-new -o t.o t.s
$ ../build/binutils/readelf -A t.o
Attribute Section: aeabi
File Attributes
  Tag_CPU_arch: v6T2
  Tag_THUMB_ISA_use: Thumb-2

$ ../build/binutils/objdump -d t.o

t.o:     file format elf32-littlearm

Disassembly of section .text:

00000000 <foo>:
   0:   4288            cmp     r0, r1
   2:   d0fd            beq.n   0 <foo>

There is no thumb2 instruction used in final t.o. But the architecture is
over-promoted to a thumb2 target. With this proposal and other patches, I
can get more accurate results:

$ ../build/binutils/readelf -A t.o
Attribute Section: aeabi
File Attributes
  Tag_CPU_arch: v4T
  Tag_THUMB_ISA_use: Thumb-1

You may notice the ".syntax unified" in this case. Yes, I am trying to
enable unified syntax for thumb1 and this is the first issue that is
bothering me.

So does this proposal make sense? Please comment. Thanks in advance.


2014-09-17  Terry Guo  <>

           * as.c (create_obj_attrs_section): Move it and call it from ...
           * write.c (create_obj_attrs_section): ... here.
           (subsegs_finish_section): Refactored.

Attachment: rfc-attribute-section-after-relax-v1.txt
Description: Text document

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]