forked from Firmware/Firmwares
adds wrapping to all clib symbols
This commit is contained in:
parent
acf20a4818
commit
41f204e304
@ -50,7 +50,7 @@ LIBWRAP_SYMS := \
|
|||||||
isatty \
|
isatty \
|
||||||
times \
|
times \
|
||||||
sbrk _sbrk\
|
sbrk _sbrk\
|
||||||
_exit \
|
exit _exit \
|
||||||
puts _puts\
|
puts _puts\
|
||||||
printf \
|
printf \
|
||||||
sprintf
|
sprintf
|
||||||
@ -60,6 +60,7 @@ LIBWRAP := libwrap.a
|
|||||||
LINK_DEPS += $(LIBWRAP)
|
LINK_DEPS += $(LIBWRAP)
|
||||||
|
|
||||||
LDFLAGS += $(foreach s,$(LIBWRAP_SYMS),-Wl,--wrap=$(s))
|
LDFLAGS += $(foreach s,$(LIBWRAP_SYMS),-Wl,--wrap=$(s))
|
||||||
|
#LDFLAGS += $(foreach s,$(LIBWRAP_SYMS),-Wl,--wrap=_$(s))
|
||||||
LDFLAGS += -L. -Wl,--start-group -lwrap -lc -Wl,--end-group
|
LDFLAGS += -L. -Wl,--start-group -lwrap -lc -Wl,--end-group
|
||||||
|
|
||||||
CLEAN_OBJS += $(LIBWRAP_OBJS)
|
CLEAN_OBJS += $(LIBWRAP_OBJS)
|
||||||
|
@ -2,12 +2,13 @@
|
|||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
#include "weak_under_alias.h"
|
||||||
|
|
||||||
extern volatile uint32_t tohost;
|
extern volatile uint32_t tohost;
|
||||||
extern volatile uint32_t fromhost;
|
extern volatile uint32_t fromhost;
|
||||||
void write_hex(int fd, uint32_t hex);
|
void write_hex(int fd, uint32_t hex);
|
||||||
|
|
||||||
void __wrap__exit(int code)
|
void __wrap_exit(int code)
|
||||||
{
|
{
|
||||||
//volatile uint32_t* leds = (uint32_t*) (GPIO_BASE_ADDR + GPIO_OUT_OFFSET);
|
//volatile uint32_t* leds = (uint32_t*) (GPIO_BASE_ADDR + GPIO_OUT_OFFSET);
|
||||||
const char message[] = "\nProgam has exited with code:";
|
const char message[] = "\nProgam has exited with code:";
|
||||||
@ -20,3 +21,4 @@ void __wrap__exit(int code)
|
|||||||
write(STDERR_FILENO, "\x04", 1);
|
write(STDERR_FILENO, "\x04", 1);
|
||||||
for (;;);
|
for (;;);
|
||||||
}
|
}
|
||||||
|
weak_under_alias(exit);
|
||||||
|
@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "stub.h"
|
#include "stub.h"
|
||||||
|
#include "weak_under_alias.h"
|
||||||
|
|
||||||
int __wrap_execve(const char* name, char* const argv[], char* const env[])
|
int __wrap_execve(const char* name, char* const argv[], char* const env[])
|
||||||
{
|
{
|
||||||
return _stub(ENOMEM);
|
return _stub(ENOMEM);
|
||||||
}
|
}
|
||||||
|
weak_under_alias(execve);
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
/* See LICENSE of license details. */
|
/* See LICENSE of license details. */
|
||||||
|
#include "weak_under_alias.h"
|
||||||
|
|
||||||
int __wrap_getpid(void)
|
int __wrap_getpid(void)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
weak_under_alias(getpid);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/* See LICENSE of license details. */
|
/* See LICENSE of license details. */
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include "weak_under_alias.h"
|
||||||
|
|
||||||
int __wrap_isatty(int fd)
|
int __wrap_isatty(int fd)
|
||||||
{
|
{
|
||||||
@ -9,3 +10,4 @@ int __wrap_isatty(int fd)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
weak_under_alias(isatty);
|
||||||
|
@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "stub.h"
|
#include "stub.h"
|
||||||
|
#include "weak_under_alias.h"
|
||||||
|
|
||||||
int __wrap_kill(int pid, int sig)
|
int __wrap_kill(int pid, int sig)
|
||||||
{
|
{
|
||||||
return _stub(EINVAL);
|
return _stub(EINVAL);
|
||||||
}
|
}
|
||||||
|
weak_under_alias(kill);
|
||||||
|
@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "stub.h"
|
#include "stub.h"
|
||||||
|
#include "weak_under_alias.h"
|
||||||
|
|
||||||
int __wrap_link(const char *old_name, const char *new_name)
|
int __wrap_link(const char *old_name, const char *new_name)
|
||||||
{
|
{
|
||||||
return _stub(EMLINK);
|
return _stub(EMLINK);
|
||||||
}
|
}
|
||||||
|
weak_under_alias(link);
|
||||||
|
@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "stub.h"
|
#include "stub.h"
|
||||||
|
#include "weak_under_alias.h"
|
||||||
|
|
||||||
int __wrap_open(const char* name, int flags, int mode)
|
int __wrap_open(const char* name, int flags, int mode)
|
||||||
{
|
{
|
||||||
return _stub(ENOENT);
|
return _stub(ENOENT);
|
||||||
}
|
}
|
||||||
|
weak_under_alias(open);
|
||||||
|
@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "stub.h"
|
#include "stub.h"
|
||||||
|
#include "weak_under_alias.h"
|
||||||
|
|
||||||
int __wrap_openat(int dirfd, const char* name, int flags, int mode)
|
int __wrap_openat(int dirfd, const char* name, int flags, int mode)
|
||||||
{
|
{
|
||||||
return _stub(ENOENT);
|
return _stub(ENOENT);
|
||||||
}
|
}
|
||||||
|
weak_under_alias(openat);
|
||||||
|
@ -3,8 +3,10 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include "stub.h"
|
#include "stub.h"
|
||||||
|
#include "weak_under_alias.h"
|
||||||
|
|
||||||
int __wrap_stat(const char* file, struct stat* st)
|
int __wrap_stat(const char* file, struct stat* st)
|
||||||
{
|
{
|
||||||
return _stub(EACCES);
|
return _stub(EACCES);
|
||||||
}
|
}
|
||||||
|
weak_under_alias(stat);
|
||||||
|
@ -3,8 +3,10 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/times.h>
|
#include <sys/times.h>
|
||||||
#include "stub.h"
|
#include "stub.h"
|
||||||
|
#include "weak_under_alias.h"
|
||||||
|
|
||||||
clock_t __wrap_times(struct tms* buf)
|
clock_t __wrap_times(struct tms* buf)
|
||||||
{
|
{
|
||||||
return _stub(EACCES);
|
return _stub(EACCES);
|
||||||
}
|
}
|
||||||
|
weak_under_alias(times);
|
||||||
|
@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "stub.h"
|
#include "stub.h"
|
||||||
|
#include "weak_under_alias.h"
|
||||||
|
|
||||||
int __wrap_unlink(const char* name)
|
int __wrap_unlink(const char* name)
|
||||||
{
|
{
|
||||||
return _stub(ENOENT);
|
return _stub(ENOENT);
|
||||||
}
|
}
|
||||||
|
weak_under_alias(unlink);
|
||||||
|
Loading…
Reference in New Issue
Block a user