From 0f85b228aa3f5ea797e10e69deae54ea898cb44a Mon Sep 17 00:00:00 2001 From: Carmelo Amoroso Date: Mon, 20 Sep 2010 15:03:17 +0200 Subject: nptl: Fix libpthread build when UCLIBC_LINUX_SPECIFIC is disabled NPTL library needs both madvise and statfs symbols, that are guarded by UCLIBC_LINUX_SPECIFIC option. This fix provides these symbols too when NPTL is used, indipendently by UCLIBC_LINUX_SPECIFIC choice. Otherwise libpthread link fails as below: LD libpthread-0.9.32-git.so libpthread/nptl/libpthread_so.a(pthread_create.oS): In function `__free_tcb': pthread_create.c:(.text+0x1184): undefined reference to `madvise' libpthread/nptl/libpthread_so.a(sem_open.oS): In function `__where_is_shmfs': sem_open.c:(.text+0x764): undefined reference to `statfs' collect2: ld returned 1 exit status make: *** [lib/libpthread.so] Error 1 Signed-off-by: Carmelo Amoroso --- include/sys/mman.h | 2 +- libc/sysdeps/linux/common/Makefile.in | 6 +++++- libc/sysdeps/linux/common/statfs.c | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/include/sys/mman.h b/include/sys/mman.h index d46b92258..470209ed5 100644 --- a/include/sys/mman.h +++ b/include/sys/mman.h @@ -100,7 +100,7 @@ static __inline__ int msync (void *__addr, size_t __len, int __flags) { return 0 #endif -#if defined __USE_BSD && defined __UCLIBC_LINUX_SPECIFIC__ +#if defined __USE_BSD && (defined __UCLIBC_LINUX_SPECIFIC__ || defined __UCLIBC_HAS_THREADS_NATIVE__) /* Advise the system about particular usage patterns the program follows for the region starting at ADDR and extending LEN bytes. */ extern int madvise (void *__addr, size_t __len, int __advice) __THROW; diff --git a/libc/sysdeps/linux/common/Makefile.in b/libc/sysdeps/linux/common/Makefile.in index 1711e8025..4222912fc 100644 --- a/libc/sysdeps/linux/common/Makefile.in +++ b/libc/sysdeps/linux/common/Makefile.in @@ -26,12 +26,16 @@ endif ifneq ($(UCLIBC_LINUX_SPECIFIC),y) # we need these internally: fstatfs.c statfs.c -CSRC := $(filter-out capget.c capset.c inotify.c ioperm.c iopl.c madvise.c \ +CSRC := $(filter-out capget.c capset.c inotify.c ioperm.c iopl.c \ modify_ldt.c personality.c ppoll.c prctl.c readahead.c reboot.c \ remap_file_pages.c sched_getaffinity.c sched_setaffinity.c \ sendfile64.c sendfile.c setfsgid.c setfsuid.c setresuid.c \ splice.c vmsplice.c tee.c signalfd.c swapoff.c swapon.c \ sync_file_range.c sysctl.c sysinfo.c timerfd.c uselib.c vhangup.c,$(CSRC)) +ifneq ($(UCLIBC_HAS_THREADS_NATIVE),y) +# we need madvise.c in NPTL +CSRC := $(filter-pout madvise.c,$(CSRC)) +endif endif ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y) diff --git a/libc/sysdeps/linux/common/statfs.c b/libc/sysdeps/linux/common/statfs.c index 2f8548d0d..d24bc9d0c 100644 --- a/libc/sysdeps/linux/common/statfs.c +++ b/libc/sysdeps/linux/common/statfs.c @@ -16,6 +16,7 @@ extern __typeof(statfs) __libc_statfs attribute_hidden; #define __NR___libc_statfs __NR_statfs _syscall2(int, __libc_statfs, const char *, path, struct statfs *, buf) -#if defined __UCLIBC_LINUX_SPECIFIC__ +#if defined __UCLIBC_LINUX_SPECIFIC__ || defined __UCLIBC_HAS_THREADS_NATIVE__ +/* statfs is used by NPTL, so it must exported in case */ weak_alias(__libc_statfs,statfs) #endif -- cgit v1.2.3 From 78e6de06e7148f43453e73836bc29ab8ea5e0c16 Mon Sep 17 00:00:00 2001 From: Carmelo Amoroso Date: Wed, 22 Sep 2010 12:13:21 +0200 Subject: libc: Sort HEADERS_RM alphabetically No functional changes, just a code tidy-up. Please keep them sorted in future changes. Signed-off-by: Filippo Arcidiacono Signed-off-by: Carmelo Amoroso --- Makefile.in | 67 ++++++++++++++++++++++++------------------------------------- 1 file changed, 26 insertions(+), 41 deletions(-) diff --git a/Makefile.in b/Makefile.in index 348bc0c3f..227ddb4be 100644 --- a/Makefile.in +++ b/Makefile.in @@ -220,71 +220,56 @@ HEADERS_RM- := \ rpc/des_crypt.h \ rpc/key_prot.h \ rpc/rpc_des.h -HEADERS_RM-$(UCLIBC_HAS_UTMPX) += \ - bits/utmpx.h \ - utmpx.h -HEADERS_RM-$(UCLIBC_HAS_FLOATS) += \ - complex.h \ - fpu_control.h \ - ieee754.h \ - math.h \ - tgmath.h \ - bits/uClibc_fpmax.h \ - bits/math*.h -HEADERS_RM-$(UCLIBC_HAS_GNU_GETOPT)$(UCLIBC_HAS_GETOPT_LONG) += getopt.h -HEADERS_RM-$(UCLIBC_HAS_REALTIME) += \ - mqueue.h \ - bits/mqueue.h \ - sched.h \ - bits/sched.h \ - semaphore.h -HEADERS_RM-$(UCLIBC_HAS_THREADS) += \ - *thread*.h \ - semaphore.h \ - bits/*thread*.h \ - bits/initspin.h -HEADERS_RM-$(UCLIBC_LINUX_SPECIFIC) += \ - sys/fsuid.h \ - sys/inotify.h \ - sys/perm.h \ - sys/personality.h \ - sys/prctl.h \ - sys/reboot.h \ - sys/sendfile.h \ - sys/signalfd.h \ - bits/statfs.h \ - sys/statfs.h \ - sys/swap.h \ - sys/sysctl.h \ - sys/sysinfo.h \ - sys/vfs.h -HEADERS_RM-$(UCLIBC_HAS_THREADS_NATIVE) += \ - atomic.h \ - bits/atomic.h HEADERS_RM-$(HAVE_SHARED) += dlfcn.h bits/dlfcn.h HEADERS_RM-$(PTHREADS_DEBUG_SUPPORT) += thread_db.h HEADERS_RM-$(UCLIBC_HAS_BSD_ERR) += err.h HEADERS_RM-$(UCLIBC_HAS_CRYPT) += crypt.h HEADERS_RM-$(UCLIBC_HAS_EPOLL) += sys/epoll.h HEADERS_RM-$(UCLIBC_HAS_FENV) += fenv.h bits/fenv.h bits/fenvinline.h +HEADERS_RM-$(UCLIBC_HAS_FLOATS) += complex.h fpu_control.h ieee754.h \ + math.h \ + tgmath.h \ + bits/uClibc_fpmax.h \ + bits/math*.h HEADERS_RM-$(findstring y,$(UCLIBC_HAS_FTW)$(UCLIBC_HAS_NFTW)) += ftw.h HEADERS_RM-$(UCLIBC_HAS_GETTEXT_AWARENESS) += libintl.h HEADERS_RM-$(UCLIBC_HAS_GLIBC_CUSTOM_PRINTF) += printf.h HEADERS_RM-$(UCLIBC_HAS_GLOB) += glob.h HEADERS_RM-$(UCLIBC_HAS_GNU_ERROR) += error.h +HEADERS_RM-$(UCLIBC_HAS_GNU_GETOPT)$(UCLIBC_HAS_GETOPT_LONG) += getopt.h HEADERS_RM-$(UCLIBC_HAS_IPV6) += netinet/ip6.h netinet/icmp6.h HEADERS_RM-$(UCLIBC_HAS_BACKTRACE) += execinfo.h HEADERS_RM-$(UCLIBC_HAS_LOCALE) += iconv.h HEADERS_RM-$(UCLIBC_HAS_PTY) += pty.h +HEADERS_RM-$(UCLIBC_HAS_REALTIME) += mqueue.h bits/mqueue.h sched.h \ + bits/sched.h \ + semaphore.h HEADERS_RM-$(UCLIBC_HAS_REGEX) += regex.h regexp.h HEADERS_RM-$(UCLIBC_HAS_RPC) += rpc HEADERS_RM-$(UCLIBC_HAS_SHADOW) += shadow.h HEADERS_RM-$(UCLIBC_HAS_SOCKET) += sys/socket.h bits/socket.h sys/socketvar.h HEADERS_RM-$(UCLIBC_HAS_SYSLOG) += syslog.h sys/syslog.h bits/syslog*.h +HEADERS_RM-$(UCLIBC_HAS_THREADS) += *thread*.h semaphore.h \ + bits/*thread*.h \ + bits/initspin.h +HEADERS_RM-$(UCLIBC_HAS_THREADS_NATIVE) += atomic.h bits/atomic.h +HEADERS_RM-$(UCLIBC_HAS_UTMPX) += bits/utmpx.h utmpx.h HEADERS_RM-$(UCLIBC_HAS_WCHAR) += wchar.h wctype.h HEADERS_RM-$(UCLIBC_HAS_WORDEXP) += wordexp.h HEADERS_RM-$(UCLIBC_HAS_XATTR) += sys/xattr.h HEADERS_RM-$(UCLIBC_HAS_XLOCALE) += xlocale.h +HEADERS_RM-$(UCLIBC_LINUX_SPECIFIC) += sys/fsuid.h sys/inotify.h sys/perm.h \ + sys/personality.h \ + sys/prctl.h \ + sys/reboot.h \ + sys/sendfile.h \ + sys/signalfd.h \ + bits/statfs.h \ + sys/statfs.h \ + sys/swap.h \ + sys/sysctl.h \ + sys/sysinfo.h \ + sys/vfs.h HEADERS_RM-$(UCLIBC_SUPPORT_AI_ADDRCONFIG) += ifaddrs.h HEADERS_RM-$(UCLIBC_SV4_DEPRECATED) += ustat.h sys/ustat.h bits/ustat.h HEADERS_RM-$(UCLIBC_SUSV3_LEGACY) += sys/timeb.h regexp.h -- cgit v1.2.3 From 74407db52d3953c7f3c6b8a53661cfc96cb07e22 Mon Sep 17 00:00:00 2001 From: Salvatore Cro Date: Thu, 23 Sep 2010 12:01:20 +0200 Subject: ldso_sh: add support for protected symbols to SH Protected symbols should not be overridden by symbols from other modules. Such symbols are exported i.e. globally visible, but references from whithin defining modules are satisfied locally. Signed-off-by: Salvatore Cro Signed-off-by: Carmelo Amoroso --- ldso/ldso/sh/elfinterp.c | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/ldso/ldso/sh/elfinterp.c b/ldso/ldso/sh/elfinterp.c index 715eadc15..756f6c443 100644 --- a/ldso/ldso/sh/elfinterp.c +++ b/ldso/ldso/sh/elfinterp.c @@ -166,26 +166,32 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope, reloc_type = ELF32_R_TYPE(rpnt->r_info); symtab_index = ELF32_R_SYM(rpnt->r_info); symbol_addr = 0; - symname = strtab + symtab[symtab_index].st_name; if (symtab_index) { - symbol_addr = (unsigned long) _dl_find_hash(symname, scope, tpnt, - elf_machine_type_class(reloc_type), &tls_tpnt); - /* - * We want to allow undefined references to weak symbols - this might - * have been intentional. We should not be linking local symbols - * here, so all bases should be covered. - */ - - if (!symbol_addr - && (ELF_ST_TYPE(symtab[symtab_index].st_info) != STT_TLS) - && (ELF32_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK)) { - _dl_dprintf(2, "%s: can't resolve symbol '%s'\n", - _dl_progname, strtab + symtab[symtab_index].st_name); - - /* Let the caller to handle the error: it may be non fatal if called from dlopen */ - return 1; - } + symname = strtab + symtab[symtab_index].st_name; + if (ELF32_ST_VISIBILITY(symtab[symtab_index].st_other) + != STV_PROTECTED) { + symbol_addr = (unsigned long) _dl_find_hash(symname, scope, tpnt, + elf_machine_type_class(reloc_type), &tls_tpnt); + /* + * We want to allow undefined references to weak symbols - this might + * have been intentional. We should not be linking local symbols + * here, so all bases should be covered. + */ + + if (!symbol_addr + && (ELF_ST_TYPE(symtab[symtab_index].st_info) != STT_TLS) + && (ELF32_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK)) { + _dl_dprintf(2, "%s: can't resolve symbol '%s'\n", + _dl_progname, strtab + symtab[symtab_index].st_name); + + /* Let the caller to handle the error: it may be non fatal if called from dlopen */ + return 1; + } + } else + /* Resolve protected symbols locally */ + symbol_addr = DL_FIND_HASH_VALUE(tpnt, elf_machine_type_class(reloc_type), + &symtab[symtab_index]); } #if defined (__SUPPORT_LD_DEBUG__) -- cgit v1.2.3