Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 389536 Details for
Bug 528558
sys-libs/glibc-2.20: TLS init crashes on hardened
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
benchmarking
time-syscall.c (text/x-c), 2.38 KB, created by
Anthony Basile
on 2014-11-16 20:48:37 UTC
(
hide
)
Description:
benchmarking
Filename:
MIME Type:
Creator:
Anthony Basile
Created:
2014-11-16 20:48:37 UTC
Size:
2.38 KB
patch
obsolete
>/* Compile with `gcc -fno-stack-protector -m32 -O1 -o time-syscall time-syscall.c` */ > >#include <stdio.h> >#include <sys/types.h> >#include <unistd.h> >#include <syscall.h> >#include <time.h> > >pid_t getpid_int80() { > register unsigned int ret=__NR_getpid; > asm volatile ( > "int $0x80\n\t" > : "+&a" (ret) > : > : "memory", "cc" > ); > return (pid_t)ret; >} > >pid_t getpid_vsyscall() { > register unsigned int ret = __NR_getpid; > asm volatile ( > "call *%%gs:0x10\n\t" > : "+&a" (ret) > : > : "memory", "cc" > ); > return (pid_t)ret; >} > > >static void * got_vsyscall; >void init_got() { > asm volatile ( > "movl %%gs:0x10, %0\n\t" > : "=r" (got_vsyscall) > : > : "memory", "cc" > ); >} > >pid_t getpid_vsyscall_got() { > register unsigned int ret = __NR_getpid; > asm volatile ( > "call *%1" > : "+&a" (ret) > : "m" (got_vsyscall) > : "memory", "cc" > ); > return (pid_t)ret; >} > >#define LOOPS 100000000 > >int main( int argc, char* argv[] ) { > pid_t p, q, r, s; > int i; > clock_t before, after; > > before = clock(); > for (i = 0; i < LOOPS; i++) > p = getpid_int80(); > after = clock(); > printf("time-int80 = %lf\n", (double)(after-before)/(double)CLOCKS_PER_SEC); > > before = clock(); > for (i = 0; i < LOOPS; i++) > q = getpid_vsyscall(); > after = clock(); > printf("time-vsyscall = %lf\n", (double)(after-before)/(double)CLOCKS_PER_SEC); > > init_got(); > before = clock(); > for (i = 0; i < LOOPS; i++) > r = getpid_vsyscall_got(); > after = clock(); > printf("time-got = %lf\n", (double)(after-before)/(double)CLOCKS_PER_SEC); > > before = clock(); > for (i = 0; i < LOOPS; i++) > s = getpid(); > after = clock(); > printf("time-libc = %lf\n", (double)(after-before)/(double)CLOCKS_PER_SEC); > > printf("pid_int80 = %ld, pid_vsyscal = %ld, pid_got = %ld, pid_libc = %ld\n", (long)p, (long)q, (long)r, (long)s); > >} > >/* >pid_t getpid_int80() { > register unsigned int ret; > asm volatile ( > "int $0x80\n\t" > : "=a" (ret) > : "a" (__NR_getpid) > : "memory", "cc" > ); > return (pid_t)ret; >} > >static unsigned int temp; >pid_t getpid_vsyscall() { > asm volatile ( > "movl $20, %eax\n\t" > "call *%gs:0x10\n\t" > "movl %eax, temp\n\t" > ); > return (pid_t)temp; >} >*/
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 528558
:
388780
|
388884
|
388886
|
388960
|
389152
| 389536