Bug 1519165

Summary: annobin: Produces invalid assembly if the target attribute used
Product: [Fedora] Fedora Reporter: Florian Weimer <fweimer>
Component: annobinAssignee: Florian Weimer <fweimer>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: urgent    
Version: rawhideCC: mpolacek, nickc
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: annobin-2.5.1-3.fc28 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-11-30 19:44:18 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1518823    
Attachments:
Description Flags
funname.patch
none
funname.patch none

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.