Skip to content

Instantly share code, notes, and snippets.

@ice799
Created July 20, 2010 20:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ice799/483494 to your computer and use it in GitHub Desktop.
Save ice799/483494 to your computer and use it in GitHub Desktop.
[joe@x:/home/joe]% uname -a
Linux x.com 2.6.32.3 #3 SMP Thu Feb 4 23:11:14 UTC 2010 x86_64 GNU/Linux
[joe@x:/home/joe]% cat /proc/version
Linux version 2.6.32.3 (root@x.com) (gcc version 4.3.2 (Debian 4.3.2-1.1) ) #3 SMP Thu Feb 4 23:11:14 UTC 2010
[joe@x:/home/joe]% cat x.i
typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
extern fpu_control_t __fpu_control;
struct rtld_global_ro
{
fpu_control_t _dl_fpu_control;
};
extern const struct rtld_global_ro _rtld_global_ro;
extern void __setfpucw (fpu_control_t);
int __libc_multiple_libcs __attribute__ ((visibility ("hidden"))) = 1;
int __libc_argc __attribute__ ((visibility ("hidden")));
char **__libc_argv __attribute__ ((visibility ("hidden")));
extern char **__environ;
extern void __init_misc (int, char **, char **);
extern void __libc_global_ctors (void);
extern int _dl_starting_up;
#pragma weak _dl_starting_up
void
__attribute__ ((visibility ("hidden")))
_init (int argc, char **argv, char **envp)
{
__libc_multiple_libcs = &_dl_starting_up && !_dl_starting_up;
if (!__libc_multiple_libcs
&& __fpu_control != _rtld_global_ro._dl_fpu_control)
__setfpucw (__fpu_control);
__libc_argc = argc;
__libc_argv = argv;
__environ = envp;
__init_misc (argc, argv, envp);
__libc_global_ctors ();
}
[joe@x:/home/joe]% gcc -m64 -march=core2 -fPIC -O2 x.i -c -fomit-frame-pointer
[joe@x:/home/joe]% objdump -dw x.o | grep rbp
5: 48 89 6c 24 f0 mov %rbp,-0x10(%rsp)
f: 48 89 f5 mov %rsi,%rbp
57: 48 89 2d 00 00 00 00 mov %rbp,0x0(%rip) # 5e <_init+0x5e>
6b: 48 89 ee mov %rbp,%rsi
7a: 48 8b 6c 24 08 mov 0x8(%rsp),%rbp
[joe@x:/home/joe]% objdump -dw x.o
x.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <_init>:
0: 48 89 5c 24 e8 mov %rbx,-0x18(%rsp)
5: 48 89 6c 24 f0 mov %rbp,-0x10(%rsp)
a: 4c 89 64 24 f8 mov %r12,-0x8(%rsp)
f: 48 89 f5 mov %rsi,%rbp
12: 48 83 ec 18 sub $0x18,%rsp
16: 41 89 fc mov %edi,%r12d
19: 48 8b 05 00 00 00 00 mov 0x0(%rip),%rax # 20 <_init+0x20>
20: 48 89 d3 mov %rdx,%rbx
23: 48 85 c0 test %rax,%rax
26: 75 65 jne 8d <_init+0x8d>
28: 48 8b 05 00 00 00 00 mov 0x0(%rip),%rax # 2f <_init+0x2f>
2f: c7 05 00 00 00 00 00 00 00 00 movl $0x0,0x0(%rip) # 39 <_init+0x39>
39: 0f b7 10 movzwl (%rax),%edx
3c: 48 8b 05 00 00 00 00 mov 0x0(%rip),%rax # 43 <_init+0x43>
43: 66 39 10 cmp %dx,(%rax)
46: 74 08 je 50 <_init+0x50>
48: 0f b7 fa movzwl %dx,%edi
4b: e8 00 00 00 00 callq 50 <_init+0x50>
50: 44 89 25 00 00 00 00 mov %r12d,0x0(%rip) # 57 <_init+0x57>
57: 48 89 2d 00 00 00 00 mov %rbp,0x0(%rip) # 5e <_init+0x5e>
5e: 48 8b 05 00 00 00 00 mov 0x0(%rip),%rax # 65 <_init+0x65>
65: 48 89 da mov %rbx,%rdx
68: 48 89 18 mov %rbx,(%rax)
6b: 48 89 ee mov %rbp,%rsi
6e: 44 89 e7 mov %r12d,%edi
71: e8 00 00 00 00 callq 76 <_init+0x76>
76: 48 8b 1c 24 mov (%rsp),%rbx
7a: 48 8b 6c 24 08 mov 0x8(%rsp),%rbp
7f: 4c 8b 64 24 10 mov 0x10(%rsp),%r12
84: 48 83 c4 18 add $0x18,%rsp
88: e9 00 00 00 00 jmpq 8d <_init+0x8d>
8d: 8b 00 mov (%rax),%eax
8f: 85 c0 test %eax,%eax
91: 75 95 jne 28 <_init+0x28>
93: c7 05 00 00 00 00 01 00 00 00 movl $0x1,0x0(%rip) # 9d <_init+0x9d>
9d: eb b1 jmp 50 <_init+0x50>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment