Skip to content

Commit 13d77b6

Browse files
Andrew HsiehGerrit Code Review
Andrew Hsieh
authored and
Gerrit Code Review
committed
Merge "Use linker -Wl,--wrap=symbol"
2 parents e6915e0 + 6433ec2 commit 13d77b6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+337
-262
lines changed

ndk/sources/android/libportable/arch-arm/epoll.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@
1414
* limitations under the License.
1515
*/
1616

17+
#include <portability.h>
1718
#include <sys/epoll.h>
1819

19-
int epoll_ctl_portable(int epfd, int op, int fd, struct epoll_event *event)
20+
int WRAP(epoll_ctl)(int epfd, int op, int fd, struct epoll_event *event)
2021
{
21-
return epoll_ctl(epfd, op, fd, event);
22+
return REAL(epoll_ctl)(epfd, op, fd, event);
2223
}
2324

24-
int epoll_wait_portable(int epfd, struct epoll_event *events, int max, int timeout)
25+
int WRAP(epoll_wait)(int epfd, struct epoll_event *events, int max, int timeout)
2526
{
26-
return epoll_wait(epfd, events, max, timeout);
27+
return REAL(epoll_wait)(epfd, events, max, timeout);
2728
}
2829

ndk/sources/android/libportable/arch-arm/errno.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17-
extern volatile int* __errno(void);
18-
volatile int* __errno_portable()
17+
#include <portability.h>
18+
19+
extern volatile int* REAL(__errno)(void);
20+
volatile int* WRAP(__errno)()
1921
{
20-
return __errno();
22+
return REAL(__errno)();
2123
}

ndk/sources/android/libportable/arch-arm/socket.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
* limitations under the License.
1515
*/
1616

17+
#include <portability.h>
1718
#include <unistd.h>
1819
#include <sys/socket.h>
1920
#include <sys/linux-syscalls.h>
2021

21-
int socket_portable(int domain, int type, int protocol) {
22-
return socket(domain, type, protocol);
22+
int WRAP(socket)(int domain, int type, int protocol) {
23+
return REAL(socket)(domain, type, protocol);
2324
}

ndk/sources/android/libportable/arch-arm/sockopt.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,18 @@
1414
* limitations under the License.
1515
*/
1616

17+
#include <portability.h>
1718
#include <sys/types.h>
1819
#include <sys/socket.h>
1920

2021
extern int setsockopt(int, int, int, const void *, socklen_t);
21-
int setsockopt_portable(int s, int level, int optname, const void *optval, socklen_t optlen)
22+
int WRAP(setsockopt)(int s, int level, int optname, const void *optval, socklen_t optlen)
2223
{
23-
return setsockopt(s, level, optname, optval, optlen);
24+
return REAL(setsockopt)(s, level, optname, optval, optlen);
2425
}
2526

2627
extern int getsockopt (int, int, int, void *, socklen_t *);
27-
int getsockopt_portable(int s, int level, int optname, void *optval, socklen_t *optlen)
28+
int WRAP(getsockopt)(int s, int level, int optname, void *optval, socklen_t *optlen)
2829
{
29-
return getsockopt(s, level, optname, optval, optlen);
30+
return REAL(getsockopt)(s, level, optname, optval, optlen);
3031
}

ndk/sources/android/libportable/arch-arm/stat.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,26 @@
1414
* limitations under the License.
1515
*/
1616

17+
#include <portability.h>
1718
#include <stat_portable.h>
1819

1920
/* Note: The Portable Header will define stat to stat_portable */
20-
int stat_portable(const char *path, struct stat_portable *s)
21+
int WRAP(stat)(const char *path, struct stat_portable *s)
2122
{
22-
return stat(path, s);
23+
return REAL(stat)(path, s);
2324
}
2425

25-
int fstat_portable(int fd, struct stat_portable *s)
26+
int WRAP(fstat)(int fd, struct stat_portable *s)
2627
{
27-
return fstat(fd, s);
28-
}
28+
return REAL(fstat)(fd, s);
29+
}
2930

30-
int lstat_portable(const char *path, struct stat_portable *s)
31+
int WRAP(lstat)(const char *path, struct stat_portable *s)
3132
{
32-
return lstat(path, s);
33+
return REAL(lstat)(path, s);
3334
}
3435

35-
int fstatat_portable(int dirfd, const char *path, struct stat_portable *s, int flags)
36+
int WRAP(fstatat)(int dirfd, const char *path, struct stat_portable *s, int flags)
3637
{
37-
return fstatat(dirfd, path, s, flags);
38+
return REAL(fstatat)(dirfd, path, s, flags);
3839
}

ndk/sources/android/libportable/arch-arm/unwind.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17+
#include <portability.h>
1718
#include <stdint.h>
1819

1920
struct _Unwind_Context;
@@ -55,25 +56,25 @@ _Unwind_VRS_Result _Unwind_VRS_Set(struct _Unwind_Context *context,
5556
#define UNWIND_STACK_REG 13
5657
#define UNWIND_IP_REG 15
5758

58-
uint64_t _Unwind_GetGR_portable(struct _Unwind_Context* ctx, int index) {
59+
uint64_t WRAP(_Unwind_GetGR)(struct _Unwind_Context* ctx, int index) {
5960
uint32_t val;
6061
_Unwind_VRS_Get(ctx, _UVRSC_CORE, index, _UVRSD_UINT32, &val);
6162
return (uint64_t)val;
6263
}
6364

64-
void _Unwind_SetGR_portable(struct _Unwind_Context* ctx, int index, uint64_t new_value) {
65+
void WRAP(_Unwind_SetGR)(struct _Unwind_Context* ctx, int index, uint64_t new_value) {
6566
uint32_t val = (uint32_t)new_value;
6667
_Unwind_VRS_Set(ctx, _UVRSC_CORE, index, _UVRSD_UINT32, &val);
6768
}
6869

69-
uint64_t _Unwind_GetIP_portable(struct _Unwind_Context* ctx) {
70-
return _Unwind_GetGR_portable(ctx, UNWIND_IP_REG) & ~1; // thumb bit
70+
uint64_t WRAP(_Unwind_GetIP)(struct _Unwind_Context* ctx) {
71+
return WRAP(_Unwind_GetGR)(ctx, UNWIND_IP_REG) & ~1; // thumb bit
7172
}
7273

73-
void _Unwind_SetIP_portable(struct _Unwind_Context* ctx, uintptr_t new_value) {
74+
void WRAP(_Unwind_SetIP)(struct _Unwind_Context* ctx, uintptr_t new_value) {
7475
uint32_t val = (uint32_t)new_value;
7576
// Propagate thumb bit to instruction pointer
76-
uint32_t thumbState = _Unwind_GetGR_portable(ctx, UNWIND_IP_REG) & 1;
77+
uint32_t thumbState = WRAP(_Unwind_GetGR)(ctx, UNWIND_IP_REG) & 1;
7778
uint64_t new_val = (uint64_t)(val | thumbState);
78-
_Unwind_SetGR_portable(ctx, UNWIND_IP_REG, new_val);
79+
WRAP(_Unwind_SetGR)(ctx, UNWIND_IP_REG, new_val);
7980
}

ndk/sources/android/libportable/arch-mips/clone.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
#define _GNU_SOURCE
18+
#include <portability.h>
1819
#include <sched.h>
1920
#include <stdarg.h>
2021
#include <stdlib.h>
@@ -47,7 +48,7 @@
4748
* If no signal is specified, then the parent process is not
4849
* signaled when the child terminates.
4950
*/
50-
int clone_portable(int (*fn)(void *), void *child_stack, int port_flags, void *arg, ...)
51+
int WRAP(clone)(int (*fn)(void *), void *child_stack, int port_flags, void *arg, ...)
5152
{
5253
va_list args;
5354
int ret;
@@ -117,7 +118,7 @@ int clone_portable(int (*fn)(void *), void *child_stack, int port_flags, void *a
117118
ALOGV("%s: clone(%p, %p, 0x%x, %p, %p, %p, %p);", __func__,
118119
fn, child_stack, mips_flags, arg, parent_tidptr, new_tls, child_tidptr);
119120

120-
ret = clone(fn, child_stack, mips_flags, arg, parent_tidptr,
121+
ret = REAL(clone)(fn, child_stack, mips_flags, arg, parent_tidptr,
121122
new_tls, child_tidptr);
122123

123124
if (ret > 0) {

ndk/sources/android/libportable/arch-mips/epoll.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@
1414
* limitations under the License.
1515
*/
1616

17+
#include <portability.h>
1718
#include <sys/epoll.h>
1819

19-
int epoll_ctl_portable(int epfd, int op, int fd, struct epoll_event *event)
20+
int WRAP(epoll_ctl)(int epfd, int op, int fd, struct epoll_event *event)
2021
{
21-
return epoll_ctl(epfd, op, fd, event);
22+
return REAL(epoll_ctl)(epfd, op, fd, event);
2223
}
2324

24-
int epoll_wait_portable(int epfd, struct epoll_event *events, int max, int timeout)
25+
int WRAP(epoll_wait)(int epfd, struct epoll_event *events, int max, int timeout)
2526
{
26-
return epoll_wait(epfd, events, max, timeout);
27+
return REAL(epoll_wait)(epfd, events, max, timeout);
2728
}
2829

ndk/sources/android/libportable/arch-mips/errno.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17+
#include <portability.h>
1718
#include <pthread.h>
1819
#include <string.h>
1920
#include <errno.h>
@@ -278,7 +279,7 @@ static struct errno_state *errno_key_data(void)
278279
* This can be assigned to without affecting the native errno. If the key
279280
* allocation fails fall back to using the native errno location.
280281
*/
281-
volatile int* __errno_portable()
282+
volatile int* WRAP(__errno)()
282283
{
283284
struct errno_state *p;
284285
int save_errno;
@@ -331,7 +332,7 @@ volatile int* __errno_portable()
331332

332333

333334
/* set portable errno */
334-
void __set_errno_portable(int portable_errno)
335+
void WRAP(__set_errno)(int portable_errno)
335336
{
336337
struct errno_state *p;
337338
int save_errno;
@@ -356,13 +357,14 @@ void __set_errno_portable(int portable_errno)
356357
ALOGV("%s: return; }", __func__);
357358
}
358359

359-
char *strerror_portable(int errnum)
360+
extern char* REAL(strerror)(int);
361+
char *WRAP(strerror)(int errnum)
360362
{
361-
return strerror(errno_pton(errnum));
363+
return REAL(strerror)(errno_pton(errnum));
362364
}
363365

364366
/* BSD style strerror_r */
365-
int strerror_r_portable(int errnum, char *buf, size_t buflen)
367+
int WRAP(strerror_r)(int errnum, char *buf, size_t buflen)
366368
{
367-
return strerror_r(errno_pton(errnum), buf, buflen);
369+
return REAL(strerror_r)(errno_pton(errnum), buf, buflen);
368370
}

ndk/sources/android/libportable/arch-mips/eventfd.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17+
#include <portability.h>
1718
#include <unistd.h>
1819
#include <fcntl.h>
1920

@@ -71,7 +72,7 @@ static inline int efd_flags_pton(int portable_flags)
7172
* new eventfd2 system call number, so it likely best to just use
7273
* the Android eventfd() for both eventfd and eventfd2 system calls.
7374
*/
74-
int eventfd_portable(unsigned int initval, int portable_flags) {
75+
int WRAP(eventfd)(unsigned int initval, int portable_flags) {
7576
int rv;
7677
int native_flags;
7778

@@ -81,7 +82,7 @@ int eventfd_portable(unsigned int initval, int portable_flags) {
8182

8283
native_flags = efd_flags_pton(portable_flags);
8384

84-
rv = eventfd(initval, native_flags);
85+
rv = REAL(eventfd)(initval, native_flags);
8586
if (rv >= 0) {
8687
if (native_flags & EFD_CLOEXEC) {
8788
filefd_CLOEXEC_enabled(rv);

ndk/sources/android/libportable/arch-mips/fcntl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17+
#include <portability.h>
1718
#include <fcntl.h>
1819
#include <errno.h>
1920
#include <stdarg.h>
@@ -284,7 +285,7 @@ extern int __fcntl64(int, int, void *);
284285
* pid_t l_pid; pid_t l_pid;
285286
* } }
286287
*/
287-
int fcntl_portable(int fd, int portable_cmd, ...)
288+
int WRAP(fcntl)(int fd, int portable_cmd, ...)
288289
{
289290
int flags;
290291
va_list ap;

ndk/sources/android/libportable/arch-mips/filefd.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17+
#include <portability.h>
1718
#include <unistd.h>
1819
#include <stdarg.h>
1920
#include <stdlib.h>
20-
#include <portability.h>
2121
#include <stdio.h>
2222
#include <errno.h>
2323
#include <errno_portable.h>
@@ -415,22 +415,22 @@ __hidden void filefd_disable_mapping()
415415
}
416416

417417

418-
int close_portable(int fd)
418+
int WRAP(close)(int fd)
419419
{
420420
int rv;
421421

422422
ALOGV(" ");
423423
ALOGV("%s(fd:%d) {", __func__, fd);
424424

425-
rv = close(fd);
425+
rv = REAL(close)(fd);
426426
filefd_closed(fd);
427427

428428
ALOGV("%s: return(rv:%d); }", __func__, rv);
429429
return rv;
430430
}
431431

432432

433-
int read_portable(int fd, void *buf, size_t count)
433+
int WRAP(read)(int fd, void *buf, size_t count)
434434
{
435435
int rv;
436436
enum filefd_type fd_type;
@@ -449,21 +449,21 @@ int read_portable(int fd, void *buf, size_t count)
449449
case EVENT_FD_TYPE:
450450
case INOTIFY_FD_TYPE:
451451
case TIMER_FD_TYPE:
452-
rv = read(fd, buf, count);
452+
rv = REAL(read)(fd, buf, count);
453453
break;
454454

455455
/* The read() of a signalfd() file descriptor needs to be mapped. */
456456
case SIGNAL_FD_TYPE:
457457
if (filefd_enabled) {
458458
rv = read_signalfd_mapper(fd, buf, count);
459459
} else {
460-
rv = read(fd, buf, count);
460+
rv = REAL(read)(fd, buf, count);
461461
}
462462
break;
463463

464464
default:
465465
ALOGE("Unknown fd_type:%d!", fd_type);
466-
rv = read(fd, buf, count);
466+
rv = REAL(read)(fd, buf, count);
467467
break;
468468
}
469469

@@ -477,7 +477,7 @@ int read_portable(int fd, void *buf, size_t count)
477477
* Tries a second time if it detects an extremely unlikely
478478
* race condition.
479479
*/
480-
int execve_portable(const char *filename, char *const argv[], char *const envp[])
480+
int WRAP(execve)(const char *filename, char *const argv[], char *const envp[])
481481
{
482482
int rv;
483483
int mapped_files = filefd_mapped_files;
@@ -494,7 +494,7 @@ int execve_portable(const char *filename, char *const argv[], char *const envp[
494494
}
495495
import_fd_env(verify_consistancy); /* File type table consistancy verified. */
496496

497-
rv = execve(filename, argv, envp);
497+
rv = REAL(execve)(filename, argv, envp);
498498

499499
ALOGV("%s: return(rv:%d); }", __func__, rv);
500500
return rv;

ndk/sources/android/libportable/arch-mips/flags.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17+
#include <portability.h>
1718
#include <stdio.h>
1819
#include <fcntl.h>
1920
#include <fcntl_portable.h>
@@ -26,7 +27,7 @@
2627
extern int __sflags(const char *, int *);
2728

2829
int
29-
__sflags_portable(const char *mode, int *optr)
30+
WRAP(__sflags)(const char *mode, int *optr)
3031
{
3132
int rv;
3233
int nflags, pflags;

ndk/sources/android/libportable/arch-mips/inotify.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17+
#include <portability.h>
1718
#include <unistd.h>
1819
#include <fcntl.h>
1920

@@ -60,7 +61,7 @@ static inline int in_flags_pton(int portable_flags)
6061
}
6162

6263

63-
int inotify_init1_portable(int portable_flags) {
64+
int WRAP(inotify_init1)(int portable_flags) {
6465
int rv;
6566
int native_flags;
6667

0 commit comments

Comments
 (0)