This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ make libab.so | |
gcc -Wall -fPIC -fvisibility=hidden -c -o filea.o filea.c | |
gcc -Wall -fPIC -fvisibility=hidden -c -o fileb.o fileb.c | |
gcc -Wall -fPIC -fvisibility=hidden -shared -o libab.so filea.o fileb.o | |
$ strip --strip-all --discard-all libab.so | |
$ objdump -T libab.so | grep get | |
Exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ strip --strip-all --discard-all libab.so | |
$ objdump -t libab.so | |
libab.so: file format elf64-x86-64 | |
SYMBOL TABLE: | |
no symbols | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ make | |
gcc -Wall -fPIC -c -o test.o test.c | |
gcc -Wall -fPIC -c -o filea.o filea.c | |
gcc -Wall -fPIC -c -o fileb.o fileb.c | |
gcc -shared -o libab.so filea.o fileb.o | |
gcc -o test test.o -L. -lab | |
$ objdump -t libab.so | grep get | |
00000000000005dc l F .text 000000000000000b a_internal_getval | |
0000000000000634 l F .text 000000000000000b b_internal_getval |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* fileb.c */ | |
/* Internal to this file. */ | |
static int | |
b_internal_getval(void) | |
{ | |
return 4; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* filea.c */ | |
#include <stdio.h> | |
/* Include public API definitions. */ | |
#include "ab.h" | |
/* Function provided by fileb.c */ | |
int b_getval_super_secret(void); | |
/* Simple function internal to this file only. */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ab.h -- External API for libab. */ | |
#ifndef __AB_H__ | |
#define __AB_H__ | |
const char *ab_get_string(void); | |
#endif /* ! __AB_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ gcc -g3 -Wall -fPIC -shared -o condwait_wrap.so condwait_wrap.c -ldl -lpthread -Wl,--version-script -Wl,VERSION.txt | |
$ LD_PRELOAD=./condwait_wrap.so ./condwait_test | |
Calling condwait v. 2.3.2 with cond: 0x600d80, mutex: 0x600dc0.....got it! | |
Thread exiting | |
$ objdump -t condwait_wrap.so | grep pthread_cond_wait | |
000000000000074a l F .text 000000000000006c pthread_cond_wait_225 | |
00000000000007b6 l F .text 000000000000006c pthread_cond_wait_232 | |
00000000000007b6 g F .text 000000000000006c pthread_cond_wait@@GLIBC_2.3.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GLIBC_2.2.5 { | |
global: | |
pthread_cond_wait; | |
local: | |
*; | |
}; | |
GLIBC_2.3.2 { | |
global: | |
pthread_cond_wait; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ gcc -g3 -Wall -fPIC -shared -o condwait_wrap.so condwait_wrap.c -ldl -lpthread | |
/usr/bin/ld: condwait_wrap.so: version node not found for symbol pthread_cond_wait@@GLIBC_2.3.2 | |
/usr/bin/ld: failed to set dynamic section sizes: Bad value | |
collect2: ld returned 1 exit status | |
Exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define _GNU_SOURCE | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <dlfcn.h> | |
#include <pthread.h> | |
static int (*condwait_internal_225)(pthread_cond_t *cond, | |
pthread_mutex_t *mutex); | |
static int (*condwait_internal_232)(pthread_cond_t *cond, |