Bug 1519165 - annobin: Produces invalid assembly if the target attribute used
Summary: annobin: Produces invalid assembly if the target attribute used
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: annobin
Version: rawhide
Hardware: Unspecified
OS: Unspecified
urgent
high
Target Milestone: ---
Assignee: Florian Weimer
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 1518823
TreeView+ depends on / blocked
 
Reported: 2017-11-30 10:32 UTC by Florian Weimer
Modified: 2017-11-30 19:44 UTC (History)
2 users (show)

Fixed In Version: annobin-2.5.1-3.fc28
Clone Of:
Environment:
Last Closed: 2017-11-30 19:44:18 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
funname.patch (5.84 KB, patch)
2017-11-30 17:51 UTC, Florian Weimer
no flags Details | Diff
funname.patch (6.62 KB, patch)
2017-11-30 18:00 UTC, Florian Weimer
no flags Details | Diff

Description Florian Weimer 2017-11-30 10:32:05 UTC
This program:

__attribute__((__target__("sse4.2")))
int
sum (int a, int b, int c)
{ 
  return a + b + c;
}

When compiled using

  g++ --specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -S -o- -O2 mangled.cc

produces this assembler output:

…
        .popsection
        .text
        .p2align 4,,15
        .globl  _Z3sumiii
        .type   _Z3sumiii, @function
_Z3sumiii:
.LFB0:
        .cfi_startproc
        addl    %esi, %edi
        leal    (%rdi,%rdx), %eax
        ret
        .cfi_endproc
.LFE0:
        .size   _Z3sumiii, .-_Z3sumiii
        .pushsection .gnu.build.attributes
        .dc.l 12                # size of name
        .dc.l 8         # descsz = sizeof (address)
        .dc.l 0x101     # type = FUNC
        .dc.b 0x47, 0x41, 0x2a, 0x6, 0x12, 0, 0, 0x40, 0x44, 0x2, 0x5e, 0       # name (numeric: ABI)
        .quad int sum(int, int, int)    # description (symbol name)
        .popsection


The problem is the unmangled symbol in the .quad output, which is not valid assembler syntax.

Comment 1 Florian Weimer 2017-11-30 16:29:22 UTC
The problem is the use of current_function_name.  It uses a langhook to produce the demangled version of the name, which is not appropriate.  We need the assembler symbol here.

Comment 2 Florian Weimer 2017-11-30 17:51:23 UTC
Created attachment 1361087 [details]
funname.patch

The patch I'm going to use.

Comment 3 Florian Weimer 2017-11-30 18:00:15 UTC
Created attachment 1361098 [details]
funname.patch

This version also updates the aarch64 code.


Note You need to log in before you can comment on or make changes to this bug.