Re: __attribute__((alias(foo))) and the hardening flags

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

 



On Thu, Mar 12, 2015 at 7:09 PM, Kevin Kofler <kevin.kofler@xxxxxxxxx> wrote:
> Don't use __attribute__((alias(foo_gmp))), use asm("foo_gmp"), as per:
> https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/Asm-Labels.html

We need both names available, the "_gmp"-suffixed version for
polymake, and the standard version for everything else.  The asm trick
doesn't seem to accomplish that.  Here is the contents of test.c:

extern int foo_gmp (int x) asm ("foo");

int foo_gmp (int x) {
  return x + 1;
}

extern int bar (int x) __attribute__((alias("bar_gmp")));

int bar_gmp (int x) {
  return x - 1;
}

Compile with something like "gcc -c test.c", then run "readelf -a
test.o".  You'll see the symbol table looks like this:

Symbol table '.symtab' contains 17 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS test.c
     2: 0000000000000000     0 SECTION LOCAL  DEFAULT    1
     3: 0000000000000000     0 SECTION LOCAL  DEFAULT    2
     4: 0000000000000000     0 SECTION LOCAL  DEFAULT    3
     5: 0000000000000000     0 SECTION LOCAL  DEFAULT    4
     6: 0000000000000000     0 SECTION LOCAL  DEFAULT    5
     7: 0000000000000000     0 SECTION LOCAL  DEFAULT    7
     8: 0000000000000000     0 SECTION LOCAL  DEFAULT    8
     9: 0000000000000000     0 SECTION LOCAL  DEFAULT   10
    10: 0000000000000000     0 SECTION LOCAL  DEFAULT   12
    11: 0000000000000000     0 SECTION LOCAL  DEFAULT   14
    12: 0000000000000000     0 SECTION LOCAL  DEFAULT   15
    13: 0000000000000000     0 SECTION LOCAL  DEFAULT   13
    14: 0000000000000000     4 FUNC    GLOBAL DEFAULT    1 foo
    15: 0000000000000010     4 FUNC    GLOBAL DEFAULT    1 bar_gmp
    16: 0000000000000010     4 FUNC    GLOBAL DEFAULT    1 bar

So the asm approach changes the name that is emitted, rather than
aliasing it.  Thanks for the suggestion, though.
-- 
Jerry James
http://www.jamezone.org/
-- 
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxxx
https://admin.fedoraproject.org/mailman/listinfo/devel
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]
  Powered by Linux