[PATCH] D30724: Dont emit Mapping symbols for sections that contain only data.

Shankar Easwaran via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 21 10:18:21 PDT 2017


shankare added inline comments.


================
Comment at: lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp:630-631
+    // executable permissions.
+    if (LastEMS != EMS_None ||
+        (cast<MCSectionELF>(getCurrentSectionOnly()))->UseCodeAlign()) {
+      LastEMSInfo->resetInfo();
----------------
t.p.northover wrote:
> shankare wrote:
> > t.p.northover wrote:
> > > shankare wrote:
> > > > t.p.northover wrote:
> > > > > I still don't see why we need this `UseCodeAlign` special case, I'm afraid.
> > > > The only time that we want to emit a Data symbol is if the section was set to be executable but it contains data. 
> > > > 
> > > > 
> > > Why? The ABI says nothing about an executable bit:
> > > 
> > >    "A section must have a mapping symbol defined at the beginning of the section; however, if the section contains only data then the mapping symbol may be omitted."
> > If the section is marked as containing instructions(on elf using the section flag, UseCodeAlign checks for section permission) and it contains data, dont we need a $d to specifiy beginning of data. 
> > 
> > GCC does it as the below test shows :-
> > 
> > The section foobar has a section flag below to specify that it contains instructions.
> > 
> > $ cat b.s
> >         .section        .foobar,"ax",%progbits
> >          .word 32
> > 
> > $ readelf -s b.o
> > 
> > Symbol table '.symtab' contains 7 entries:
> >    Num:    Value  Size Type    Bind   Vis      Ndx Name
> >      0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND
> >      1: 00000000     0 SECTION LOCAL  DEFAULT    1
> >      2: 00000000     0 SECTION LOCAL  DEFAULT    2
> >      3: 00000000     0 SECTION LOCAL  DEFAULT    3
> >      4: 00000000     0 SECTION LOCAL  DEFAULT    4
> >      5: 00000000     0 NOTYPE  LOCAL  DEFAULT    4 $d
> >      6: 00000000     0 SECTION LOCAL  DEFAULT    5
> > 
> Not according to how I read the ABI. It's quite possible GNU as adds unneeded symbols in that case, but  I don't think "because GCC does it" is reason enough for us to add this complexity when we've got an actual document telling us what we should be doing.
How would objdump or anytool be able to find out that an executable section is having data ? Without adding a mapping symbol I believe it would be hard for objdump to figure out that information. 


https://reviews.llvm.org/D30724





More information about the llvm-commits mailing list