nuttx/names: add symbol name preprocessing support

Change-Id: I54e0b24391b6e08801e3f0b1799ed3fcc9188ae7
Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
chao.an 2020-06-17 17:41:35 +08:00 committed by patacongo
parent 1a59e5ad0f
commit 6e8cf28e9c
4 changed files with 212 additions and 200 deletions

View File

@ -1,8 +1,4 @@
/Cygwin-names.dat
/Darwin-names.dat
/Msys-names.dat
/Linux-names.dat
/nuttx-names.dat
/hostfs.h
/GNU
/chip
/board

View File

@ -228,7 +228,7 @@ OBJS = $(AOBJS) $(COBJS) $(HOSTOBJS)
# Override in Make.defs if linker is not 'ld'
ifeq ($(HOSTOS),Darwin)
LDUNEXPORTSYMBOLS ?= -unexported_symbols_list $(HOSTOS)-names.dat
LDUNEXPORTSYMBOLS ?= -unexported_symbols_list nuttx-names.dat
else
LDSTARTGROUP ?= --start-group
LDENDGROUP ?= --end-group
@ -277,30 +277,14 @@ board/libboard$(LIBEXT):
# A partially linked object containing only NuttX code (no interface to host OS)
# Change the names of most symbols that conflict with libc symbols.
GNU:
$(Q) mkdir -p ./GNU
nuttx-names.dat: nuttx-names.in
$(call PREPROCESS, $<, $@)
GNU/Linux-names.dat: GNU nuttx-names.dat
$(Q) cp nuttx-names.dat $@
Msys-names.dat: GNU nuttx-names.dat
$(Q) cp nuttx-names.dat $@
Cygwin-names.dat: nuttx-names.dat
ifeq ($())CONFIG_SIM_CYGWIN_DECORATED),y)
$(Q) cat $^ | sed -e "s/^/_/g" >$@
else
$(Q) cp nuttx-names.dat $@
endif
Darwin-names.dat: nuttx-names.dat
$(Q) cat $^ | sed -e "s/^\([^[:space:]][^[:space:]]*\)[[:space:]].*/_\1/g" >$@
nuttx.rel : libarch$(LIBEXT) board/libboard$(LIBEXT) $(HOSTOS)-names.dat $(LINKOBJS)
nuttx.rel : libarch$(LIBEXT) board/libboard$(LIBEXT) nuttx-names.dat $(LINKOBJS)
$(Q) echo "LD: nuttx.rel"
$(Q) $(LD) -r $(LDLINKFLAGS) $(RELPATHS) $(EXTRA_LIBPATHS) -o $@ $(REQUIREDOBJS) $(LDSTARTGROUP) $(RELLIBS) $(EXTRA_LIBS) $(LDENDGROUP) $(LDUNEXPORTSYMBOLS)
ifneq ($(HOSTOS),Darwin)
$(Q) $(OBJCOPY) --redefine-syms=$(HOSTOS)-names.dat $@
$(Q) $(OBJCOPY) --redefine-syms=nuttx-names.dat $@
endif
# Generate the final NuttX binary by linking the host-specific objects with the NuttX
@ -332,7 +316,7 @@ export_startup: board/libboard$(LIBEXT) up_head.o $(HOSTOBJS)
depend: .depend
cleanrel:
$(Q) rm -f nuttx.rel $(HOSTOS)-names.dat
$(Q) rm -f nuttx.rel nuttx-names.dat
clean: cleanrel
$(Q) if [ -e board/Makefile ]; then \
@ -349,6 +333,5 @@ distclean: clean
$(call DELFILE, Make.dep)
$(call DELFILE, .depend)
$(call DELFILE, hostfs.h)
$(Q) rm -rf GNU
-include Make.dep

View File

@ -1,172 +0,0 @@
__errno NX__errno
_exit NX_exit
accept NXaccept
asprintf NXasprintf
basename NXbasename
bind NXbind
calloc NXcalloc
chdir NXchdir
clearenv NXclearenv
clock NXclock
clock_gettime NXclock_gettime
clock_settime NXclock_settime
close NXclose
closedir NXclosedir
connect NXconnect
dup NXdup
dup2 NXdup2
exit NXexit
fclose NXfclose
fcntl NXfcntl
fdopen NXfdopen
fgetc NXfgetc
fopen NXfopen
fprintf NXfprintf
fputc NXfputc
fputs NXfputs
fread NXfread
free NXfree
fseek NXfseek
fstat NXfstat
fsync NXfsync
ftell NXftell
ftruncate NXftruncate
fwrite NXfwrite
getchar NXgetchar
getenv NXgetenv
getopt NXgetopt
getpid NXgetpid
gettimeofday NXgettimeofday
htons NXhtons
if_indextoname NXif_indextoname
if_nametoindex NXif_nametoindex
ioctl NXioctl
isatty NXisatty
kill NXkill
link NXlink
listen NXlisten
lseek NXlseek
mallinfo NXmallinfo
malloc NXmalloc
malloc_init NXmalloc_init
memcmp NXmemcmp
memcpy NXmemcpy
memset NXmemset
mkdir NXmkdir
mkfifo NXmkfifo
mktime NXmktime
mmap NXmmap
mount NXmount
mq_close NXmq_close
munmap NXmunmap
nanosleep NXnanosleep
ntohs NXhntohs
open NXopen
opendir NXopendir
optarg NXoptarg
optind NXoptind
optopt NXoptopt
perror NXperror
pipe NXpipe
poll NXpoll
printf NXprintf
pthread_create NXpthread_create
pthread_detach NXpthread_detach
pthread_exit NXpthread_exit
pthread_getspecific NXpthread_getspecific
pthread_join NXpthread_join
pthread_key_create NXpthread_key_create
pthread_kill NXpthread_kill
pthread_mutex_destroy NXpthread_mutex_destroy
pthread_mutex_init NXpthread_mutex_init
pthread_mutex_lock NXpthread_mutex_lock
pthread_mutex_unlock NXpthread_mutex_unlock
pthread_setcancelstate NXpthread_setcancelstate
pthread_setcanceltype NXpthread_setcanceltype
pthread_setspecific NXpthread_setspecific
pthread_sigmask NXpthread_sigmask
pthread_testcancel NXpthread_testcancel
pthread_yield NXpthread_yield
ptsname NXptsname
ptsname_r NXptsname_r
putenv NXputenv
puts NXputs
read NXread
readdir NXreaddir
readlink NXreadlink
realloc NXrealloc
recv NXrecv
recvfrom NXrecvfrom
rename NXrename
rewinddir NXrewinddir
rmdir NXrmdir
sched_setparam NXsched_setparam
sched_yield NXsched_yield
seekdir NXseekdir
select NXselect
sem_destroy NXsem_destroy
sem_getvalue NXsem_getvalue
sem_init NXsem_init
sem_post NXsem_post
sem_timedwait NXsem_timedwait
sem_trywait NXsem_trywait
sem_wait NXsem_wait
send NXsend
sendto NXsendto
setenv NXsetenv
setlogmask NXsetlogmask
setsockopt NXsetsockopt
setvbuf NXsetvbuf
sigaction NXsigaction
sigaddset NXsigaddset
sigdelset NXsigdelset
sigemptyset NXsigemptyset
sigfillset NXsigfillset
sighold NXsighold
sigismember NXsigismember
sigprocmask NXsigprocmask
sigrelse NXsigrelse
sigtimedwait NXsigtimedwait
sleep NXsleep
snprintf NXsnprintf
socket NXsocket
sprintf NXsprintf
stat NXstat
statfs NXstatfs
strcat NXstrcat
strchr NXstrchr
strcmp NXstrcmp
strcpy NXstrcpy
strcspn NXstrcspn
strdup NXstrdup
strerror NXstrerror
strerror_r NXstrerror_r
strftime NXstrftime
strlen NXstrlen
strncasecmp NXstrncasecmp
strncmp NXstrncmp
strncpy NXstrncpy
strnlen NXstrnlen
strrchr NXstrrchr
strstr NXstrstr
strtok_r NXstrtok_r
strtol NXstrtol
strtoul NXstrtoul
syslog NXsyslog
system NXsystem
tcgetattr NXtcgetattr
tcsetattr NXtcsetattr
umount2 NXumount2
uname NXuname
unlink NXunlink
unlockpt NXunlockpt
unsetenv NXunsetenv
usleep NXusleep
vasprintf NXvasprintf
vfork NXvfork
vfprintf NXvfprintf
vsnprintf NXvsnprintf
vsyslog NXvsyslog
waitpid NXwaitpid
write NXwrite
zmalloc NXzmalloc

205
arch/sim/src/nuttx-names.in Normal file
View File

@ -0,0 +1,205 @@
/****************************************************************************
* arch/sim/src/nuttx-names.in
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#include <nuttx/config.h>
#define CONCAT_(x, y) x##y
#define CONCAT(x, y) CONCAT_(x, y)
#if defined(CONFIG_HOST_MACOS)
#define NXSYMBOLS(s) _##s
#elif defined(CONFIG_HOST_WINDOWS) && defined(CONFIG_SIM_CYGWIN_DECORATED)
#define NXSYMBOLS(s) _##s NX##s
#else
#define NXSYMBOLS(s) s NX##s
#endif
NXSYMBOLS(__errno)
NXSYMBOLS(_exit)
NXSYMBOLS(accept)
NXSYMBOLS(asprintf)
NXSYMBOLS(basename)
NXSYMBOLS(bind)
NXSYMBOLS(calloc)
NXSYMBOLS(chdir)
NXSYMBOLS(clearenv)
NXSYMBOLS(clock)
NXSYMBOLS(clock_gettime)
NXSYMBOLS(clock_settime)
NXSYMBOLS(close)
NXSYMBOLS(closedir)
NXSYMBOLS(connect)
NXSYMBOLS(dup)
NXSYMBOLS(dup2)
NXSYMBOLS(exit)
NXSYMBOLS(fclose)
NXSYMBOLS(fcntl)
NXSYMBOLS(fdopen)
NXSYMBOLS(fgetc)
NXSYMBOLS(fopen)
NXSYMBOLS(fprintf)
NXSYMBOLS(fputc)
NXSYMBOLS(fputs)
NXSYMBOLS(fread)
NXSYMBOLS(free)
NXSYMBOLS(fseek)
NXSYMBOLS(fstat)
NXSYMBOLS(fsync)
NXSYMBOLS(ftell)
NXSYMBOLS(ftruncate)
NXSYMBOLS(fwrite)
NXSYMBOLS(getchar)
NXSYMBOLS(getenv)
NXSYMBOLS(getopt)
NXSYMBOLS(getpid)
NXSYMBOLS(gettimeofday)
NXSYMBOLS(htons)
NXSYMBOLS(if_indextoname)
NXSYMBOLS(if_nametoindex)
NXSYMBOLS(ioctl)
NXSYMBOLS(isatty)
NXSYMBOLS(kill)
NXSYMBOLS(link)
NXSYMBOLS(listen)
NXSYMBOLS(lseek)
NXSYMBOLS(mallinfo)
NXSYMBOLS(malloc)
NXSYMBOLS(malloc_init)
NXSYMBOLS(memcmp)
NXSYMBOLS(memcpy)
NXSYMBOLS(memset)
NXSYMBOLS(mkdir)
NXSYMBOLS(mkfifo)
NXSYMBOLS(mktime)
NXSYMBOLS(mmap)
NXSYMBOLS(mount)
NXSYMBOLS(mq_close)
NXSYMBOLS(munmap)
NXSYMBOLS(nanosleep)
NXSYMBOLS(ntohs)
NXSYMBOLS(open)
NXSYMBOLS(opendir)
NXSYMBOLS(optarg)
NXSYMBOLS(optind)
NXSYMBOLS(optopt)
NXSYMBOLS(perror)
NXSYMBOLS(pipe)
NXSYMBOLS(poll)
NXSYMBOLS(printf)
NXSYMBOLS(pthread_create)
NXSYMBOLS(pthread_detach)
NXSYMBOLS(pthread_exit)
NXSYMBOLS(pthread_getspecific)
NXSYMBOLS(pthread_join)
NXSYMBOLS(pthread_key_create)
NXSYMBOLS(pthread_kill)
NXSYMBOLS(pthread_mutex_destroy)
NXSYMBOLS(pthread_mutex_init)
NXSYMBOLS(pthread_mutex_lock)
NXSYMBOLS(pthread_mutex_unlock)
NXSYMBOLS(pthread_setcancelstate)
NXSYMBOLS(pthread_setcanceltype)
NXSYMBOLS(pthread_setspecific)
NXSYMBOLS(pthread_sigmask)
NXSYMBOLS(pthread_testcancel)
NXSYMBOLS(pthread_yield)
NXSYMBOLS(ptsname)
NXSYMBOLS(ptsname_r)
NXSYMBOLS(putenv)
NXSYMBOLS(puts)
NXSYMBOLS(read)
NXSYMBOLS(readdir)
NXSYMBOLS(readlink)
NXSYMBOLS(realloc)
NXSYMBOLS(recv)
NXSYMBOLS(recvfrom)
NXSYMBOLS(rename)
NXSYMBOLS(rewinddir)
NXSYMBOLS(rmdir)
NXSYMBOLS(sched_setparam)
NXSYMBOLS(sched_yield)
NXSYMBOLS(seekdir)
NXSYMBOLS(select)
NXSYMBOLS(sem_destroy)
NXSYMBOLS(sem_getvalue)
NXSYMBOLS(sem_init)
NXSYMBOLS(sem_post)
NXSYMBOLS(sem_timedwait)
NXSYMBOLS(sem_trywait)
NXSYMBOLS(sem_wait)
NXSYMBOLS(send)
NXSYMBOLS(sendto)
NXSYMBOLS(setenv)
NXSYMBOLS(setlogmask)
NXSYMBOLS(setsockopt)
NXSYMBOLS(setvbuf)
NXSYMBOLS(sigaction)
NXSYMBOLS(sigaddset)
NXSYMBOLS(sigdelset)
NXSYMBOLS(sigemptyset)
NXSYMBOLS(sigfillset)
NXSYMBOLS(sighold)
NXSYMBOLS(sigismember)
NXSYMBOLS(sigprocmask)
NXSYMBOLS(sigrelse)
NXSYMBOLS(sigtimedwait)
NXSYMBOLS(sleep)
NXSYMBOLS(snprintf)
NXSYMBOLS(socket)
NXSYMBOLS(sprintf)
NXSYMBOLS(stat)
NXSYMBOLS(statfs)
NXSYMBOLS(strcat)
NXSYMBOLS(strchr)
NXSYMBOLS(strcmp)
NXSYMBOLS(strcpy)
NXSYMBOLS(strcspn)
NXSYMBOLS(strdup)
NXSYMBOLS(strerror)
NXSYMBOLS(strerror_r)
NXSYMBOLS(strftime)
NXSYMBOLS(strlen)
NXSYMBOLS(strncasecmp)
NXSYMBOLS(strncmp)
NXSYMBOLS(strncpy)
NXSYMBOLS(strnlen)
NXSYMBOLS(strrchr)
NXSYMBOLS(strstr)
NXSYMBOLS(strtok_r)
NXSYMBOLS(strtol)
NXSYMBOLS(strtoul)
NXSYMBOLS(syslog)
NXSYMBOLS(system)
NXSYMBOLS(tcgetattr)
NXSYMBOLS(tcsetattr)
NXSYMBOLS(umount2)
NXSYMBOLS(uname)
NXSYMBOLS(unlink)
NXSYMBOLS(unlockpt)
NXSYMBOLS(unsetenv)
NXSYMBOLS(usleep)
NXSYMBOLS(vasprintf)
NXSYMBOLS(vfork)
NXSYMBOLS(vfprintf)
NXSYMBOLS(vsnprintf)
NXSYMBOLS(vsyslog)
NXSYMBOLS(waitpid)
NXSYMBOLS(write)
NXSYMBOLS(zmalloc)