This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "uClibc-ng - small C library for embedded systems".
The branch, master has been updated via 858975765a62b4db0f0e28e2063c95d5190563a9 (commit) via 9930f8b92bb47b2dbea7679d948e3ecfbce23ca9 (commit) via c058c0578db7b036fabdda6f98be567232d00e6e (commit) via e158f13f3d80bd7a4e85c026a30fc85e06beb368 (commit) via 8c79e4541e1258220be822670b22b1b9572e70a8 (commit) via dc19aa547995f92b89449ed9ebb69ea08b2098ca (commit) via 5e3820a8c616be4eaa1bdd1a55a713cb3a564537 (commit) via 62775f4518169222d70d9ba2465e938df236aef9 (commit) via 7a8856c38c50a2790443bd2c03d5f4d4c8c36fe5 (commit) via 274f3c84562cbba1d99bab2d085d22d8aa401a4e (commit) via ec0827d3c2af5c9569c04cbb6f57a3c581583722 (commit) via fe7d30e6337f280a451ac057f47d48349b63e462 (commit) via bfbcc35b0ff8e40570a99872fd538e344d8c7f75 (commit) via 62175247d977c087e62f067d4db1445f88b61e7b (commit) via 5b691e38f45e3fed19aea98775f79ab9cc00783f (commit) via 9a1e4d650edcefc4eff9aa1a6e58949f91cdc80d (commit) via 3010966c6dc170425452d0dda4922aaf1585b6b5 (commit) via d5ecf4cf9e5479246c355b8accb85af291271ee8 (commit) via 22176277c87aaf8d9f9a1fcf48e5a9b1e7872191 (commit) via f1f98784e65ce9621a570af50998b1940e7fb81d (commit) via 6173ee4f61b1c7a9c2c670952f9a18345e614c90 (commit) via e71fc570caec4f2d4bbe729dfe9eb41bfe5a732a (commit) via 298f58e073b2782bd264edea969769b7b5e7cf41 (commit) via 7c78a5c52b2db6bb0d6e163b38897a003a289958 (commit) via 8e04c064c4cb39bae5e5bec166c762d2fc88cb11 (commit) via 9058b43530b6be9146ea3448e8a5f642c09a1818 (commit) via c78cc48514723c9182a4fb5baa35bd59b8485cc7 (commit) via 03cc2041fc21889ca2256d0f1de76683bed4e94e (commit) via efc26521e8c8cda6430efe9a8ed1b73896b655b5 (commit) via a8cf23486eef67c359c295e8da3cb39cadf87f79 (commit) via a68d786f309fa1ac5478b5b60d5b6fa0b5de7b7c (commit) via 19c4bf396ead620a84051102e7f0914200fcc5e0 (commit) via 04cd09eb3a4856e9dc31112170290e3baa3bf9fb (commit) via 1df50b08dfe4133d306156483a224f5a478f7dff (commit) via f820f4ce071ae0985d84e09ea74dc42d55081e86 (commit) via cf0234de47b019ac24e2d361d6386fdfad48f119 (commit) via 5fe8fc1ac4b5eb0f9e9bb01295c14b99d80ab41e (commit) via e51d746b4b9ed54ddeed48d9e65ffd0811298c49 (commit) via 5f374c1fe85a1da95c15a5cac217f8ab762ce6dd (commit) via 3a14ea8812e8695b5205a70431d513fb905c0daf (commit) from 157a65f1ec49022ae14310d773b7b9668e05dfae (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- commit 858975765a62b4db0f0e28e2063c95d5190563a9 Merge: 157a65f 9930f8b Author: Waldemar Brodkorb wbx@openadk.org Date: Thu Jun 4 16:54:18 2015 -0500
resolve merge conflicts
-----------------------------------------------------------------------
Summary of changes: Makefile.help | 4 +- Makefile.in | 14 +- Makerules | 35 ++-- Rules.mak | 17 +- extra/Configs/Config.h8300 | 5 +- extra/Configs/defconfigs/arc/arcv2_defconfig | 7 + extra/Configs/defconfigs/arc/defconfig | 7 + extra/locale/Makefile.in | 12 +- include/.gitignore | 1 + include/libc-symbols.h | 2 +- include/stdint.h | 10 - ldso/include/ldsodefs.h | 2 + ldso/ldso/Makefile.in | 14 +- ldso/ldso/arm/dl-startup.h | 12 +- ldso/ldso/arm/resolve.S | 18 +- ldso/ldso/dl-tls.c | 9 +- ldso/ldso/h8300/dl-sysdep.h | 1 + ldso/ldso/ldso.c | 3 +- libc/Makefile.in | 3 +- libc/inet/ifaddrs.c | 13 +- libc/misc/pthread/tsd.c | 11 +- libc/misc/time/time.c | 24 +++ libc/stdio/_scanf.c | 51 +++-- libc/string/arm/_memcpy.S | 18 +- libc/string/arm/memcmp.S | 12 +- libc/string/arm/memset.S | 13 +- libc/string/arm/strcmp.S | 6 +- libc/string/arm/strlen.S | 7 +- libc/sysdeps/linux/Makefile.commonarch | 18 +- libc/sysdeps/linux/alpha/bits/siginfo.h | 11 + libc/sysdeps/linux/arm/__longjmp.S | 7 +- libc/sysdeps/linux/arm/bits/arm_asm.h | 12 +- libc/sysdeps/linux/arm/bits/arm_bx.h | 12 +- libc/sysdeps/linux/arm/bits/syscalls.h | 25 ++- libc/sysdeps/linux/arm/bits/uClibc_arch_features.h | 26 +++ libc/sysdeps/linux/arm/clone.S | 7 +- libc/sysdeps/linux/arm/mmap64.S | 6 +- libc/sysdeps/linux/arm/syscall-eabi.S | 8 +- libc/sysdeps/linux/arm/sysdep.h | 14 +- libc/sysdeps/linux/arm/vfork.S | 12 +- libc/sysdeps/linux/common/bits/siginfo.h | 11 + libc/sysdeps/linux/h8300/Makefile | 70 +------ libc/sysdeps/linux/h8300/Makefile.arch | 10 + libc/sysdeps/linux/h8300/__longjmp.S | 6 +- libc/sysdeps/linux/h8300/bits/byteswap.h | 15 +- libc/sysdeps/linux/h8300/bits/fcntl.h | 7 +- libc/sysdeps/linux/h8300/bits/kernel_stat.h | 50 ----- libc/sysdeps/linux/h8300/bits/kernel_types.h | 13 ++ libc/sysdeps/linux/h8300/bits/syscalls.h | 214 +++++++------------- .../linux/h8300/bits/uClibc_arch_features.h | 2 +- libc/sysdeps/linux/h8300/bsd-_setjmp.S | 10 +- libc/sysdeps/linux/h8300/bsd-setjmp.S | 13 +- libc/sysdeps/linux/h8300/clone.S | 36 +++- libc/sysdeps/linux/h8300/{crt0.S => crt1.S} | 38 +++- libc/sysdeps/linux/h8300/crti.S | 8 +- libc/sysdeps/linux/h8300/crtn.S | 4 +- libc/sysdeps/linux/h8300/setjmp.S | 4 +- libc/sysdeps/linux/h8300/vfork.S | 54 +++-- libc/sysdeps/linux/ia64/bits/siginfo.h | 11 + libc/sysdeps/linux/mips/bits/siginfo.h | 11 + libc/sysdeps/linux/sparc/bits/siginfo.h | 11 + libpthread/nptl/Makefile.in | 2 +- libpthread/nptl/sysdeps/Makefile.commonarch | 2 +- libpthread/nptl/sysdeps/pthread/Makefile.in | 2 +- .../sysdeps/unix/sysv/linux/Makefile.commonarch | 2 +- libpthread/nptl_db/ChangeLog | 23 +++ libpthread/nptl_db/Makefile.in | 8 +- libpthread/nptl_db/db_info.c | 4 +- libpthread/nptl_db/structs.def | 3 +- libpthread/nptl_db/td_ta_map_lwp2thr.c | 69 +++++-- libpthread/nptl_db/td_ta_thr_iter.c | 25 ++- libpthread/nptl_db/td_thr_event_enable.c | 24 ++- libpthread/nptl_db/td_thr_get_info.c | 81 +++++--- libpthread/nptl_db/td_thr_getfpregs.c | 7 +- libpthread/nptl_db/td_thr_getgregs.c | 7 +- libpthread/nptl_db/td_thr_setfpregs.c | 7 +- libpthread/nptl_db/td_thr_setgregs.c | 7 +- libpthread/nptl_db/td_thr_tlsbase.c | 25 ++- libpthread/nptl_db/td_thr_validate.c | 16 +- libpthread/nptl_db/thread_dbP.h | 5 +- librt/Makefile.in | 24 ++- librt/dso_handle.c | 5 + test/silly/Makefile.in | 8 +- test/stdio/scanf_m.c | 24 +++ utils/getconf.c | 1 + 85 files changed, 806 insertions(+), 662 deletions(-) create mode 100644 ldso/ldso/h8300/dl-sysdep.h create mode 100644 libc/sysdeps/linux/h8300/Makefile.arch delete mode 100644 libc/sysdeps/linux/h8300/bits/kernel_stat.h rename libc/sysdeps/linux/h8300/{crt0.S => crt1.S} (66%) create mode 100644 librt/dso_handle.c create mode 100644 test/stdio/scanf_m.c
diff --git a/Makefile.help b/Makefile.help index abc6471..f6c7627 100644 --- a/Makefile.help +++ b/Makefile.help @@ -53,8 +53,8 @@ help: @echo 'Environment variables:' @echo ' O=<abspath> - Use <abspath> as object directory' @echo ' V="" - Quiet build (default)' - @echo ' V=1 - Brief build (show defines, ld flags)' - @echo ' V=2 - Very verbose build' + @echo ' V=1 - Very verbose build (show full commands)' + @echo ' V=2 - Brief build (show defines, ld flags)' @echo ' CROSS_COMPILE= - Override CROSS_COMPILER_PREFIX from .config' @echo ' ARCH= - Use given arch for config targets' @echo ' SHELL= - Shell to use for make' diff --git a/Makefile.in b/Makefile.in index 72458c1..79e5632 100644 --- a/Makefile.in +++ b/Makefile.in @@ -13,7 +13,7 @@ sub_headers := headers
ifeq ($(HAVE_DOT_CONFIG),y)
-all: pregen libs +all: pregen libs startfiles libs: pregen
# In this section, we need .config @@ -29,6 +29,7 @@ headers:
endif # ifeq ($(HAVE_DOT_CONFIG),y)
+include $(top_srcdir)extra/locale/Makefile.in include $(top_srcdir)ldso/Makefile.in include $(top_srcdir)libcrypt/Makefile.in include $(top_srcdir)libintl/Makefile.in @@ -39,7 +40,6 @@ include $(top_srcdir)libutil/Makefile.in include $(top_srcdir)libpthread/Makefile.in include $(top_srcdir)librt/Makefile.in include $(top_srcdir)libubacktrace/Makefile.in -include $(top_srcdir)extra/locale/Makefile.in
# last included to catch all the objects added by others (locales/threads) include $(top_srcdir)libc/Makefile.in @@ -57,8 +57,9 @@ ifeq ($(HAVE_DOT_CONFIG),y) $(top_builddir)include/bits/uClibc_config.h: $(conf) $(KCONFIG_CONFIG) $(top_srcdir)extra/scripts/conf-header.sh | $(top_builddir)include/bits @$(disp_gen) $(Q)$< -s $(Kconfig) - $(Q)$(top_srcdir)extra/scripts/conf-header.sh $(KCONFIG_CONFIG) > $@ + $(Q)$(top_srcdir)extra/scripts/conf-header.sh $(KCONFIG_CONFIG) > $@.tmp $(Q)$(MAKE) headers-y + $(Q)mv $@.tmp $@
# The above doesn't work for threads, though. Just using check-symlinks for now. # XXX: FIXME: this is ugly @@ -183,8 +184,9 @@ headers-y += $(target-headers-sysdep)
headers: $(top_builddir)include/bits/uClibc_config.h | subdirs subdirs: $(addprefix $(top_builddir),$(subdirs)) -pregen-headers: $(top_builddir)include/bits/sysnum.h $(pregen-headers-y) -pregen: headers pregen-headers + +$(pregen-headers-y): $(headers_dep) +pregen: headers $(pregen-headers-y) $(headers_dep) $(Q)$(if $(UCLIBC_HAS_LOCALE),$(MAKE) -C extra/locale locale_headers)
$(top_builddir)include/bits/sysnum.h: $(top_srcdir)extra/scripts/gen_bits_syscall_h.sh | $(top_builddir)include/bits @@ -215,8 +217,6 @@ install: install_runtime install_dev
RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB=$(shell $(top_srcdir)extra/scripts/relative_path.sh $(DEVEL_PREFIX)$(MULTILIB_DIR) $(RUNTIME_PREFIX)$(MULTILIB_DIR))
-startfiles: $(crt-y) - $(top_builddir)extra/scripts/unifdef: |$(top_builddir)extra/scripts $(top_builddir)extra/scripts/unifdef: $(top_srcdir)extra/scripts/unifdef.c $(hcompile.u) diff --git a/Makerules b/Makerules index 1060e1f..aa24a61 100644 --- a/Makerules +++ b/Makerules @@ -22,9 +22,9 @@ ifeq ($(UCLIBC_FORMAT_SHARED_FLAT),y) libs: $(lib-gdb-y) endif libs: $(lib-a-y) -$(lib-a-y): | $(top_builddir)lib endif objs: all_objs +$(lib-so-y) $(lib-a-y): | $(top_builddir)lib
# apply unconditional per-directory flags define add_IS_IN_lib @@ -94,7 +94,7 @@ else export MAKE_IS_SILENT := n SECHO := @echo ifneq ($(V)$(VERBOSE),) -ifeq ($(V),1) +ifeq ($(V),2) DISP := bri# brief, like pur but with defines Q := @ else @@ -326,22 +326,13 @@ endef cmd_hcompile.u = $(HOSTCC) $(filter-out $(PHONY),$^) $(DEPS-$(notdir $@)) -o $@ $(BUILD_LDFLAGS) $(BUILD_LDFLAGS-$(notdir $(^D))) $(BUILD_LDFLAGS-$(notdir $@)) $(BUILD_CFLAGS) $(BUILD_CFLAGS-$(notdir $(^D))) $(BUILD_CFLAGS-$(notdir $@)) cmd_hcompile.o = $(HOSTCC) $(filter-out $(PHONY),$<) $(DEPS-$(notdir $@)) -c -o $@ $(BUILD_CFLAGS) $(BUILD_CFLAGS-$(notdir $(^D))) $(BUILD_CFLAGS-$(notdir $@))
-define create-lds - $(Q)$(RM) $@.lds - $(Q)$(CC) $(LDFLAG-fuse-ld) $(CPU_LDFLAGS-y) \ - -nostdlib -nostartfiles -shared -Wl,-z,combreloc \ - -Wl,-z,relro $(CFLAG_-Wl--hash-style=gnu) -Wl,-z,defs \ - -x c /dev/null -Wl,--verbose 2>&1 | LC_ALL=C \ - $(SED) -e '/^=========/,/^=========/!d;/^=========/d' \ - -e 's/^([ ]*). = .* + SIZEOF_HEADERS;/&\n\1$(SYMBOL_PREFIX)_begin = . - SIZEOF_HEADERS;/' > $@.lds -endef - define link.so $(Q)$(RM) $@ $@.$(2) $(dir $@)$(1) @$(disp_ld) $(Q)$(CC) $(LDFLAGS-$(notdir $@)) $(LDFLAGS-y-$(@F)) \ -Wl,-soname=$(notdir $@).$(2) \ - $(CFLAG_-nostdlib) -o $(dir $@)$(1) $(START_FILE-$(notdir $@)) \ + $(CFLAG_-nostdlib) $(CFLAG_-nostartfiles) \ + -o $(dir $@)$(1) $(START_FILE-$(notdir $@)) \ -Wl,--whole-archive $(firstword $^) -Wl,--no-whole-archive \ $(LIBS-$(notdir $@)) $(LIBGCC) $(END_FILE-$(notdir $@)) $(Q)$(LN) -sf $(1) $@.$(2) @@ -439,6 +430,9 @@ CTOR_TARGETS=$(top_builddir)lib/crti.o $(top_builddir)lib/crtn.o else CTOR_TARGETS:= endif +ifeq ($(HAS_NO_THREADS)$(UCLIBC_HAS_THREADS_NATIVE),) +$(lib-so-y): $(CTOR_TARGETS) +endif
ifeq ($(UCLIBC_FORMAT_FDPIC_ELF),y) CRTRELOC=$(top_builddir)lib/crtreloc.o @@ -451,18 +445,18 @@ CFLAGS-initfini.s := -S -g0 $(PICFLAG) -fno-inline-functions -finhibit-size-dire $(top_builddir)lib/initfini.s: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/initfini.c | $(top_builddir)lib $(compile.c)
-$(top_builddir)lib/defs.h: $(top_builddir)lib/initfini.s | $(top_builddir)lib - $(Q)sed -n -e '/@TESTS_BEGIN/,/@TESTS_END/p' $< | \ - gawk -f $(top_srcdir)extra/scripts/defs.awk > $@.tmp +$(top_builddir)lib/defs.h: $(top_builddir)lib/initfini.s + $(do_sed) -n -e '/@TESTS_BEGIN/,/@TESTS_END/p' $< | \ + $(AWK) -f $(top_srcdir)extra/scripts/defs.awk > $@.tmp $(Q)mv $@.tmp $@
$(top_builddir)lib/crti.S: $(top_builddir)lib/initfini.s $(top_builddir)lib/defs.h - $(Q)sed -n -e '1,/@HEADER_ENDS/p' \ + $(do_sed) -n -e '1,/@HEADER_ENDS/p' \ -e '/@_.*_PROLOG_BEGINS/,/@_.*_PROLOG_ENDS/p' \ -e '/@TRAILER_BEGINS/,$$p' $< > $@
$(top_builddir)lib/crtn.S: $(top_builddir)lib/initfini.s - $(Q)sed -n -e '1,/@HEADER_ENDS/p' \ + $(do_sed) -n -e '1,/@HEADER_ENDS/p' \ -e '/@_.*_EPILOG_BEGINS/,/@_.*_EPILOG_ENDS/p' \ -e '/@TRAILER_BEGINS/,$$p' $< > $@
@@ -476,9 +470,10 @@ endif CRTS_COMPAT :=
startfiles = $(CRTS) $(CTOR_TARGETS) $(CRTS_COMPAT) $(CRTRELOC) -$(crt-y): $(startfiles) +startfiles: $(startfiles) $(CRTS) $(CTOR_TARGETS) $(CRTS_COMPAT) $(CRTRELOC): | headers -$(CRTS) $(CTOR_TARGETS) $(CRTS_COMPAT) $(CRTRELOC) $(LINK_FLAT_CRTS) $(SHARED_START_FILES) $(SHARED_END_FILES) : | $(top_builddir)lib +$(CRTS) $(CTOR_TARGETS) $(CRTS_COMPAT) $(CRTRELOC) \ + $(LINK_FLAT_CRTS) $(SHARED_START_FILES) $(SHARED_END_FILES): | $(top_builddir)lib
$(top_builddir)lib/$(NONSHARED_LIBNAME): $(libc-nonshared-y) $(Q)$(RM) $@ diff --git a/Rules.mak b/Rules.mak index d93a77e..90cb48b 100644 --- a/Rules.mak +++ b/Rules.mak @@ -165,7 +165,8 @@ libpthread.depend := $(top_builddir)lib/libpthread.so endif interp := $(top_builddir)lib/interp.os ldso := $(top_builddir)lib/$(UCLIBC_LDSO) -headers_dep := $(top_builddir)include/bits/sysnum.h +headers_dep := $(top_builddir)include/bits/sysnum.h \ + $(top_builddir)include/bits/uClibc_config.h sub_headers := $(headers_dep)
#LIBS :=$(interp) -L$(top_builddir)lib -lc @@ -251,6 +252,7 @@ ARFLAGS:=cr
# Note: The check for -nostdlib has to be before all calls to check_ld $(eval $(call check-gcc-var,-nostdlib)) +$(eval $(call check-gcc-var,-nostartfiles)) # deliberately not named CFLAG-fuse-ld since unchecked and from user LDFLAG-fuse-ld := $(filter -fuse-ld=%,$(call qstrip,$(UCLIBC_EXTRA_CFLAGS))) # failed to merge target specific data of file /dev/null @@ -291,6 +293,8 @@ CPU_CFLAGS-y := -funsigned-char -fno-builtin
$(eval $(call check-gcc-var,-fno-asm)) CPU_CFLAGS-y += $(CFLAG_-fno-asm) +$(eval $(call check-gcc-var,-fmerge-all-constants)) +CPU_CFLAGS-y += $(CFLAG_-fmerge-all-constants)
LDADD_LIBFLOAT= ifeq ($(UCLIBC_HAS_SOFT_FLOAT),y) @@ -416,9 +420,8 @@ endif endif
ifeq ($(TARGET_ARCH),h8300) - SYMBOL_PREFIX=_ - CPU_LDFLAGS-$(CONFIG_H8300H)+= -Wl,-ms8300h - CPU_LDFLAGS-$(CONFIG_H8S) += -Wl,-ms8300s + CPU_LDFLAGS-$(CONFIG_H8300H)+= -Wl,-mh8300h_linux + CPU_LDFLAGS-$(CONFIG_H8S) += -Wl,-mh8300s_linux CPU_CFLAGS-$(CONFIG_H8300H) += -mh -mint32 CPU_CFLAGS-$(CONFIG_H8S) += -ms -mint32 endif @@ -647,14 +650,18 @@ LDFLAGS_NOSTRIP += $(CFLAG_-Wl--hash-style=gnu) endif endif
-LDFLAGS:=$(LDFLAGS_NOSTRIP) -Wl,-z,defs ifeq ($(DODEBUG),y) CFLAGS += -O0 -g3 -DDEBUG else CFLAGS += $(OPTIMIZATION) CFLAGS += $(OPTIMIZATION-$(GCC_MAJOR_VER)) CFLAGS += $(OPTIMIZATION-$(GCC_MAJOR_VER).$(GCC_MINOR_VER)) +$(eval $(call check-ld-var,-O2)) +LDFLAGS_NOSTRIP += $(CFLAG_-Wl-O2) endif + +LDFLAGS:=$(LDFLAGS_NOSTRIP) -Wl,-z,defs + ifeq ($(DOSTRIP),y) LDFLAGS += -Wl,-s else diff --git a/extra/Configs/Config.h8300 b/extra/Configs/Config.h8300 index 458851b..0c5486c 100644 --- a/extra/Configs/Config.h8300 +++ b/extra/Configs/Config.h8300 @@ -10,9 +10,10 @@ config TARGET_ARCH config FORCE_OPTIONS_FOR_ARCH bool default y - select ARCH_ANY_ENDIAN + select ARCH_BIG_ENDIAN select ARCH_HAS_NO_MMU - select ARCH_HAS_DEPRECATED_SYSCALLS + select ARCH_HAS_NO_LDSO + select HAVE_NO_PIC
choice prompt "Target Processor" diff --git a/extra/Configs/defconfigs/arc/arcv2_defconfig b/extra/Configs/defconfigs/arc/arcv2_defconfig index 7c4694e..9e34694 100644 --- a/extra/Configs/defconfigs/arc/arcv2_defconfig +++ b/extra/Configs/defconfigs/arc/arcv2_defconfig @@ -10,16 +10,23 @@ LDSO_RUNPATH=y UCLIBC_HAS_THREADS_NATIVE=y PTHREADS_DEBUG_SUPPORT=y UCLIBC_HAS_OBSTACK=y +UCLIBC_HAS_UTMPX=y +UCLIBC_HAS_UTMP=y UCLIBC_SUSV2_LEGACY=y UCLIBC_SUSV3_LEGACY=y UCLIBC_SUSV4_LEGACY=y UCLIBC_HAS_PROGRAM_INVOCATION_NAME=y +UCLIBC_HAS_LIBUTIL=y UCLIBC_HAS_OBSOLETE_BSD_SIGNAL=y UCLIBC_SV4_DEPRECATED=y +UCLIBC_HAS_IPV6=y UCLIBC_HAS_RPC=y UCLIBC_HAS_FULL_RPC=y +UCLIBC_USE_NETLINK=y +UCLIBC_SUPPORT_AI_ADDRCONFIG=y UCLIBC_HAS_RESOLVER_SUPPORT=y UCLIBC_HAS_LIBRESOLV_STUB=y +UCLIBC_HAS_LIBNSL_STUB=y UCLIBC_HAS_LOCALE=y UCLIBC_HAS_GLIBC_CUSTOM_STREAMS=y UCLIBC_HAS_NFTW=y diff --git a/extra/Configs/defconfigs/arc/defconfig b/extra/Configs/defconfigs/arc/defconfig index eebb115..bd93696 100644 --- a/extra/Configs/defconfigs/arc/defconfig +++ b/extra/Configs/defconfigs/arc/defconfig @@ -9,16 +9,23 @@ LDSO_RUNPATH=y UCLIBC_HAS_THREADS_NATIVE=y PTHREADS_DEBUG_SUPPORT=y UCLIBC_HAS_OBSTACK=y +UCLIBC_HAS_UTMPX=y +UCLIBC_HAS_UTMP=y UCLIBC_SUSV2_LEGACY=y UCLIBC_SUSV3_LEGACY=y UCLIBC_SUSV4_LEGACY=y UCLIBC_HAS_PROGRAM_INVOCATION_NAME=y +UCLIBC_HAS_LIBUTIL=y UCLIBC_HAS_OBSOLETE_BSD_SIGNAL=y UCLIBC_SV4_DEPRECATED=y +UCLIBC_HAS_IPV6=y UCLIBC_HAS_RPC=y UCLIBC_HAS_FULL_RPC=y +UCLIBC_USE_NETLINK=y +UCLIBC_SUPPORT_AI_ADDRCONFIG=y UCLIBC_HAS_RESOLVER_SUPPORT=y UCLIBC_HAS_LIBRESOLV_STUB=y +UCLIBC_HAS_LIBNSL_STUB=y UCLIBC_HAS_LOCALE=y UCLIBC_HAS_GLIBC_CUSTOM_STREAMS=y UCLIBC_HAS_NFTW=y diff --git a/extra/locale/Makefile.in b/extra/locale/Makefile.in index 3834c5c..efd07ed 100644 --- a/extra/locale/Makefile.in +++ b/extra/locale/Makefile.in @@ -29,7 +29,8 @@ BUILD_CFLAGS-gen_collate := -D_GNU_SOURCE
locale_headers-$(UCLIBC_HAS_LOCALE) := $(top_builddir)include/bits/uClibc_locale_data.h
-#DEPH-locale := $(top_builddir)include/bits/sysnum.h +headers_dep += $(locale_headers-y) + DEPH-locale := $(top_builddir)include/bits/uClibc_config.h DEPH-gen_collate := $(DEPH-locale) DEPH-gen_ldc := $(addprefix $(locale_OUT)/,c8tables.h wctables.h locale_tables.h locale_collate.h) $(DEPH-locale) @@ -46,9 +47,6 @@ locale_OBJ := $(locale_OUT)/locale_data.o
CFLAGS-locale_data.c := -D__WCHAR_ENABLED -I$(locale_OUT) -I$(locale_DIR)
-#headers-$(UCLIBC_HAS_LOCALE) += $(locale_headers-y) -headers: $(locale_headers-y) - libc-$(UCLIBC_HAS_LOCALE) += $(locale_OBJ) libc-nomulti-$(UCLIBC_HAS_LOCALE) += $(locale_OBJ)
@@ -68,7 +66,7 @@ $(locale_OUT)%.s: $(locale_OUT)%.S FORCE ; $(compile.s) $(locale_OUT)%.dep:
-locale_headers: headers $(top_builddir)include/bits/uClibc_locale_data.h +locale_headers: $(locale_headers-y)
# make sure that the host system has locales (this check is ok for uClibc/glibc) # we do not know though which locales were really enabled for libc at build time @@ -155,10 +153,10 @@ $(locale_OUT)/gen_wctype : $(locale_DIR)/gen_wctype.c
ifneq ($(V),) ifeq ($(V),1) -FLAG-locale-verbose := -v +FLAG-locale-verbose := -v -v endif ifeq ($(V),2) -FLAG-locale-verbose := -v -v +FLAG-locale-verbose := -v endif endif
diff --git a/include/.gitignore b/include/.gitignore index 636f8ee..8f86c4c 100644 --- a/include/.gitignore +++ b/include/.gitignore @@ -38,6 +38,7 @@ /sys/prctl.h /sys/procfs.h /sys/ptrace.h +/sys/random.h /sys/reg.h /sys/regdef.h /sys/signalfd.h diff --git a/include/libc-symbols.h b/include/libc-symbols.h index a87cde6..97463ac 100644 --- a/include/libc-symbols.h +++ b/include/libc-symbols.h @@ -111,7 +111,7 @@ /* Indirect stringification. Doing two levels allows * the parameter to be a macro itself. */ -#define __stringify_1(x) #x +#define __stringify_1(x...) #x #define __stringify(x) __stringify_1(x)
#ifdef __UCLIBC_HAVE_ASM_SET_DIRECTIVE__ diff --git a/include/stdint.h b/include/stdint.h index b134925..9ca8445 100644 --- a/include/stdint.h +++ b/include/stdint.h @@ -238,7 +238,6 @@ typedef unsigned long long int uintmax_t; # endif
-#if !defined(__H8300H__) && !defined(__H8300S__) /* Minimum for largest signed integral type. */ # define INTMAX_MIN (-__INT64_C(9223372036854775807)-1) /* Maximum for largest signed integral type. */ @@ -246,15 +245,6 @@ typedef unsigned long long int uintmax_t;
/* Maximum for largest unsigned integral type. */ # define UINTMAX_MAX (__UINT64_C(18446744073709551615)) -#else -/* Minimum for largest signed integral type. */ -# define INTMAX_MIN (-LONG_LONG_MAX-1) -/* Maximum for largest signed integral type. */ -# define INTMAX_MAX (LONG_LONG_MAX) - -/* Maximum for largest unsigned integral type. */ -# define UINTMAX_MAX (LONG_LONG_MAX<<1+1) -#endif
/* Limits of other integer types. */
diff --git a/ldso/include/ldsodefs.h b/ldso/include/ldsodefs.h index f17ac0c..9ae645c 100644 --- a/ldso/include/ldsodefs.h +++ b/ldso/include/ldsodefs.h @@ -111,7 +111,9 @@ EXTERN size_t _dl_tls_static_used; /* Alignment requirement of the static TLS block. */ EXTERN size_t _dl_tls_static_align; /* Function pointer for catching TLS errors. */ +#if 1 /* def _LIBC_REENTRANT */ EXTERN void **(*_dl_error_catch_tsd) (void) __attribute__ ((const)); +#endif
/* Number of additional entries in the slotinfo array of each slotinfo list element. A large number makes it almost certain take we never diff --git a/ldso/ldso/Makefile.in b/ldso/ldso/Makefile.in index cd6e492..424131c 100644 --- a/ldso/ldso/Makefile.in +++ b/ldso/ldso/Makefile.in @@ -38,10 +38,13 @@ LDFLAGS-$(UCLIBC_LDSO_NAME).so := $(LDFLAGS) else LDFLAGS-$(UCLIBC_LDSO_NAME).so := $(LDFLAGS_NOSTRIP) -Wl,-z,defs endif -LDFLAGS-$(UCLIBC_LDSO_NAME).so += -Wl,-e,$(SYMBOL_PREFIX)_start -Wl,-z,now -Wl,-Bsymbolic \ +LDFLAGS-$(UCLIBC_LDSO_NAME).so += -Wl,-e,$(SYMBOL_PREFIX)_start \ + -Wl,-z,now -Wl,-Bsymbolic \ -Wl,--export-dynamic $(CFLAG_-Wl--sort-common) -Wl,--discard-locals \ $(CFLAG_-Wl--discard-all) -Wl,--no-undefined
+LDFLAGS-$(LDSO_PRELINK_SUPPORT)-$(UCLIBC_LDSO_NAME).so += -Wl,-defsym=$(SYMBOL_PREFIX)_begin=0 + ldso_FULL_NAME := $(UCLIBC_LDSO_NAME)-$(VERSION).so
$(UCLIBC_LDSO_NAME)_DIR := $(top_srcdir)ldso/ldso @@ -67,16 +70,9 @@ ldso-y := $($(UCLIBC_LDSO_NAME)_OBJS:.o=.oS) lib-so-y += $(ldso) objclean-y += CLEAN_ldso/ldso
-ifeq ($(LDSO_PRELINK_SUPPORT),y) -# Use a specific linker script for ld.so -LDFLAGS-$(UCLIBC_LDSO_NAME).so += -T $(ldso:.$(ABI_VERSION)=).lds -endif - $(ldso): $(ldso:.$(ABI_VERSION)=) +$(ldso:.$(ABI_VERSION)=): | $(top_builddir)lib $(ldso:.$(ABI_VERSION)=): $($(UCLIBC_LDSO_NAME)_OUT)/$(UCLIBC_LDSO_NAME)_so.a -ifeq ($(LDSO_PRELINK_SUPPORT),y) - $(call create-lds) -endif $(call link.so,$(ldso_FULL_NAME),$(ABI_VERSION))
$($(UCLIBC_LDSO_NAME)_OUT)/$(UCLIBC_LDSO_NAME)_so.a: $(ldso-y) diff --git a/ldso/ldso/arm/dl-startup.h b/ldso/ldso/arm/dl-startup.h index df2c824..eb2a9a2 100644 --- a/ldso/ldso/arm/dl-startup.h +++ b/ldso/ldso/arm/dl-startup.h @@ -47,11 +47,7 @@ __asm__( " ldr r0, .L_FINI_PROC\n" " ldr r0, [sl, r0]\n" " @ jump to the user_s entry point\n" -#if defined(__USE_BX__) - " bx r6\n" -#else - " mov pc, r6\n" -#endif + " " __stringify(BX(r6)) "\n" ".L_GET_GOT:\n" " .word _GLOBAL_OFFSET_TABLE_ - .L_GOT_GOT - 4\n" ".L_SKIP_ARGS:\n" @@ -113,11 +109,7 @@ __asm__( " ldr r0, .L_FINI_PROC\n" " ldr r0, [r7, r0]\n" " @ jump to the user_s entry point\n" -#if defined(__USE_BX__) - " bx r6\n" -#else - " mov pc, r6\n" -#endif + " " __stringify(BX(r6)) "\n" "\n\n" ".L_GET_GOT:\n" " .word _GLOBAL_OFFSET_TABLE_ - .L_GOT_GOT - 4\n" diff --git a/ldso/ldso/arm/resolve.S b/ldso/ldso/arm/resolve.S index c1caf9a..7e0058e 100644 --- a/ldso/ldso/arm/resolve.S +++ b/ldso/ldso/arm/resolve.S @@ -90,12 +90,10 @@ * dl-startup.c). */
-#include <sys/syscall.h> +#include <features.h> #include <bits/arm_asm.h> #include <bits/arm_bx.h>
-#include <features.h> - #define sl r10 #define fp r11 #define ip r12 @@ -114,8 +112,8 @@ _dl_linux_resolve: @ function must branch to the real function, and that expects @ r0-r3 and lr to be as they were before the whole PLT stuff - @ ip can be trashed. - @ This routine is called after pushing lr, so we must push an odd - @ number of words to keep the stack correctly aligned. + @ This routine is called after pushing lr, so we must push an odd + @ number of words to keep the stack correctly aligned.
stmdb sp!, {r0, r1, r2, r3, r4} ldr r0, [lr, #-4] @ r0 : = [lr-4] (GOT_TABLE[1]) @@ -124,16 +122,12 @@ _dl_linux_resolve: @ ~x = -x-1, therefore ~(r1>>2) = (-((lr-ip)>>2)-1) @ = - ((lr-ip)/4) - 1 = (ip - lr - 4)/4, as required
- bl _dl_linux_resolver + bl _dl_linux_resolver
- mov ip, r0 + mov ip, r0 ldmia sp!, {r0, r1, r2, r3, r4, lr}
-#if defined(__USE_BX__) - bx ip -#else - mov pc,ip -#endif + BX(ip) #else @ In the thumb case _dl_linux_resolver is thumb. If a bl is used @ from arm code the linker will insert a stub call which, with diff --git a/ldso/ldso/dl-tls.c b/ldso/ldso/dl-tls.c index 5d6d3b9..ced20fa 100644 --- a/ldso/ldso/dl-tls.c +++ b/ldso/ldso/dl-tls.c @@ -963,8 +963,13 @@ static bool tls_init_tp_called; void ** __attribute__ ((const)) _dl_initial_error_catch_tsd (void) { - static void *data; - return &data; + static +#if 0 /* def ARCH_NEEDS_BOOTSTRAP_RELOCS */ + /* If we have to do bootstrap relocs anyway we might as well */ + __thread +# endif + void *__tsd_data; + return &__tsd_data; }
#ifdef SHARED diff --git a/ldso/ldso/h8300/dl-sysdep.h b/ldso/ldso/h8300/dl-sysdep.h new file mode 100644 index 0000000..880d048 --- /dev/null +++ b/ldso/ldso/h8300/dl-sysdep.h @@ -0,0 +1 @@ +/* dl not supported */ diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c index 7367f17..0cdc91d 100644 --- a/ldso/ldso/ldso.c +++ b/ldso/ldso/ldso.c @@ -1208,6 +1208,7 @@ of this helper program; chances are you did not intend to run this program.\n\ } #endif #ifdef __UCLIBC_HAS_SSP__ + _dl_debug_early("Setting up SSP guards\n"); /* Set up the stack checker's canary. */ stack_chk_guard = _dl_setup_stack_chk_guard (); # ifdef THREAD_SET_STACK_GUARD @@ -1280,7 +1281,7 @@ of this helper program; chances are you did not intend to run this program.\n\
}
- _dl_debug_early ("\nprelink checking: %s\n", prelinked ? "ok" : "failed"); + _dl_debug_early ("prelink checking: %s\n", prelinked ? "ok" : "failed");
if (prelinked) { if (_dl_loaded_modules->dynamic_info[DT_GNU_CONFLICT_IDX]) { diff --git a/libc/Makefile.in b/libc/Makefile.in index 9c8152d..2abc77d 100644 --- a/libc/Makefile.in +++ b/libc/Makefile.in @@ -87,8 +87,7 @@ $(libc_OUT)/libc.oS: $(libc-multi-y) | $(top_builddir)lib/libc.a $(top_builddir) $(Q)$(RM) $@ $(compile-m)
-$(top_builddir)lib/libc.a: $(libc-a-y) | $(crt-y) - $(Q)$(INSTALL) -d $(dir $@) +$(top_builddir)lib/libc.a: $(libc-a-y) $(Q)$(RM) $@ $(do_ar)
diff --git a/libc/inet/ifaddrs.c b/libc/inet/ifaddrs.c index 6d9ee89..0c93106 100644 --- a/libc/inet/ifaddrs.c +++ b/libc/inet/ifaddrs.c @@ -115,7 +115,8 @@ __netlink_request (struct netlink_handle *h, int type) { struct netlink_res *nlm_next; struct netlink_res **new_nlm_list; - static volatile size_t buf_size = 4096; + static volatile size_t buf_size = 0; + size_t this_buf_size; char *buf; struct sockaddr_nl nladdr; struct nlmsghdr *nlmh; @@ -126,7 +127,15 @@ __netlink_request (struct netlink_handle *h, int type) if (__netlink_sendreq (h, type) < 0) return -1;
- size_t this_buf_size = buf_size; + if (buf_size) + this_buf_size = buf_size; + else { +#ifdef PAGE_SIZE + this_buf_size = PAGE_SIZE; +#else + this_buf_size = __pagesize; +#endif + } if (__libc_use_alloca (this_buf_size)) buf = alloca (this_buf_size); else diff --git a/libc/misc/pthread/tsd.c b/libc/misc/pthread/tsd.c index 586ead3..3598b89 100644 --- a/libc/misc/pthread/tsd.c +++ b/libc/misc/pthread/tsd.c @@ -1,11 +1,18 @@ +/* + * Copyright (C) 2006 by Steven J. Hill sjhill@realitydiluted.com + * + * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball. + */ /* libpthread sets _dl_error_catch_tsd to point to this function. We define it here instead of in libpthread so that it doesn't need to have a TLS segment of its own just for this one pointer. */
+#include <features.h> + void **__libc_dl_error_tsd(void) __attribute__ ((const)); void ** __attribute__ ((const)) __libc_dl_error_tsd (void) { - static __thread void *data __attribute__ ((tls_model ("initial-exec"))); - return &data; + static __thread void *__tsd_data attribute_tls_model_ie; + return &__tsd_data; } diff --git a/libc/misc/time/time.c b/libc/misc/time/time.c index a3fccb2..03635d8 100644 --- a/libc/misc/time/time.c +++ b/libc/misc/time/time.c @@ -1084,7 +1084,25 @@ LOOP:
o_count = 1; if ((*(o = (CHAR_T *)p) == '%') && (*++p != '%')) { +#if 0 /* TODO, same for strptime */ + /* POSIX.1-2008 allows %0xY %+nY %-nY etc. for certain formats. + * Just accept these for all (for now) */ + const int plus = *p == '+'; + CHAR_T *q = (CHAR_T *)p; + long int o_width = __XL_NPP(strtol)(p, &q, 0 __LOCALE_ARG); + if (o_width > 0 && o_width < 256) { /* arbitrary upper limit */ + o_count = o_width; + if (plus) { + *s++ = '+'; + --count; + } + p = q; + } else { + o_count = 2; + } +#else o_count = 2; +#endif mod = ILLEGAL_SPEC; if ((*p == 'O') || (*p == 'E')) { /* modifier */ mod |= ((*p == 'O') ? NO_O_MOD : NO_E_MOD); @@ -1317,7 +1335,13 @@ ISO_LOOP: ccp = __XL_NPP(nl_langinfo)(_NL_ITEM(LC_TIME, field_val) __LOCALE_ARG); fmt_to_wc(o, ccp); } else { +#if 0 /* TODO, same for strptime */ + size_t min_count = ((i >> 1) & 3) + 1; + if (o_count < min_count) + o_count = min_count; +#else o_count = ((i >> 1) & 3) + 1; +#endif ccp = buf + o_count; do { *(char *)(--ccp) = '0' + (field_val % 10); diff --git a/libc/stdio/_scanf.c b/libc/stdio/_scanf.c index d48fd12..f2a9670 100644 --- a/libc/stdio/_scanf.c +++ b/libc/stdio/_scanf.c @@ -1351,7 +1351,20 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg) (psfs.conv_num >= CONV_c) #endif /* __UCLIBC_HAS_WCHAR__ */ { + /* We might have to handle the allocation ourselves */ + int len; + unsigned char **ptr; + b = (psfs.store ? ((unsigned char *) psfs.cur_ptr) : buf); + /* With 'm', we actually got a pointer to a pointer */ + ptr = (void *)b; + + if (psfs.flags & FLAG_MALLOC) { + len = 0; + b = NULL; + } else + len = -1; + fail = 1;
if (psfs.conv_num == CONV_c) { @@ -1359,32 +1372,28 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg) sc.width = 1; }
+ if (psfs.flags & FLAG_MALLOC) + b = malloc(sc.width); + + i = 0; while (__scan_getc(&sc) >= 0) { zero_conversions = 0; - *b = sc.cc; - b += psfs.store; + b[i] = sc.cc; + i += psfs.store; } __scan_ungetc(&sc); if (sc.width > 0) { /* Failed to read all required. */ goto DONE; } + if (psfs.flags & FLAG_MALLOC) + *ptr = b; psfs.cnt += psfs.store; goto NEXT_FMT; }
if (psfs.conv_num == CONV_s) { - /* We might have to handle the allocation ourselves */ - int len; - /* With 'm', we actually got a pointer to a pointer */ - unsigned char **ptr = (void *)b;
i = 0; - if (psfs.flags & FLAG_MALLOC) { - len = 0; - b = NULL; - } else - len = -1; - /* Yes, believe it or not, a %s conversion can store nuls. */ while ((__scan_getc(&sc) >= 0) && !isspace(sc.cc)) { zero_conversions = 0; @@ -1399,10 +1408,6 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg) fail = 0; }
- if (psfs.flags & FLAG_MALLOC) - *ptr = b; - /* The code below takes care of terminating NUL */ - b += i; } else { #ifdef __UCLIBC_HAS_WCHAR__ assert((psfs.conv_num == CONV_LEFTBRACKET) || \ @@ -1453,13 +1458,20 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg) #endif /* __UCLIBC_HAS_WCHAR__ */
+ i = 0; while (__scan_getc(&sc) >= 0) { zero_conversions = 0; if (!scanset[sc.cc]) { break; } - *b = sc.cc; - b += psfs.store; + if (i == len) { + /* Pick a size that won't trigger a lot of + * mallocs early on ... */ + len += 256; + b = realloc(b, len + 1); + } + b[i] = sc.cc; + i += psfs.store; fail = 0; } } @@ -1469,6 +1481,9 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg) if (fail) { /* nothing stored! */ goto DONE; } + if (psfs.flags & FLAG_MALLOC) + *ptr = b; + b += i; *b = 0; /* Nul-terminate string. */ psfs.cnt += psfs.store; goto NEXT_FMT; diff --git a/libc/string/arm/_memcpy.S b/libc/string/arm/_memcpy.S index c59f5b8..2999e8e 100644 --- a/libc/string/arm/_memcpy.S +++ b/libc/string/arm/_memcpy.S @@ -111,11 +111,7 @@ _memcpy: bcc .Lmemcpy_backwards
IT(t, eq) /* Quick abort for src=dst */ -#if defined(__USE_BX__) - bxeq lr -#else - moveq pc, lr -#endif + BXC(eq, lr) stmdb sp!, {r0, lr} /* memcpy() returns dest addr */ subs r2, r2, #4 blt .Lmemcpy_fl4 /* less than 4 bytes */ @@ -455,11 +451,7 @@ _memcpy: /* less than 4 bytes to go */ adds r2, r2, #4 IT(t, eq) -#if defined(__USE_BX__) - bxeq lr -#else - moveq pc, lr /* done */ -#endif + BXC(eq, lr) /* done */ /* copy the crud byte at a time */ cmp r2, #2 ldrb r3, [r1, #-1]! @@ -477,11 +469,7 @@ _memcpy: ldrgtb r3, [r1, #-1]! strgtb r3, [r0, #-1]! #endif -#if defined(__USE_BX__) - bx lr -#else - mov pc, lr -#endif + BX(lr) /* erg - unaligned destination */ .Lmemcpy_bdestul: cmp r12, #2 diff --git a/libc/string/arm/memcmp.S b/libc/string/arm/memcmp.S index 9f78415..5b9473c 100644 --- a/libc/string/arm/memcmp.S +++ b/libc/string/arm/memcmp.S @@ -67,11 +67,7 @@ memcmp: subs r2, r2, #1 IT(tt, mi) movmi r0, #0 -#if defined(__USE_BX__) - bxmi lr -#else - movmi pc, lr -#endif + BXC(mi, lr) /* ip == last src address to compare */ add ip, r0, r2 1: @@ -82,11 +78,7 @@ memcmp: cmpcs r2, r3 beq 1b sub r0, r2, r3 -#if defined(__USE_BX__) - bx lr -#else - mov pc, lr -#endif + BX(lr) #endif
.size memcmp,.-memcmp diff --git a/libc/string/arm/memset.S b/libc/string/arm/memset.S index 8ddc47e..2be4850 100644 --- a/libc/string/arm/memset.S +++ b/libc/string/arm/memset.S @@ -17,7 +17,6 @@ http://www.gnu.org/licenses/. */
#include <features.h> -#include <sys/syscall.h> #include <bits/arm_asm.h> #include <bits/arm_bx.h>
@@ -109,11 +108,7 @@ memset: 2: movs a3, a3 @ anything left? IT(t, eq) -#if defined(__USE_BX__) - bxeq lr -#else - moveq pc, lr @ nope -#endif + BXC(eq, lr) @ nope #if defined (__thumb2__) 1: strb a2, [a4], #1 @@ -131,11 +126,7 @@ memset: strb a2, [a4], $1 strb a2, [a4], $1 strb a2, [a4], $1 -#if defined(__USE_BX__) - bx lr -#else - mov pc, lr -#endif + BX(lr) #endif #endif
diff --git a/libc/string/arm/strcmp.S b/libc/string/arm/strcmp.S index 8b77ab0..81416a9 100644 --- a/libc/string/arm/strcmp.S +++ b/libc/string/arm/strcmp.S @@ -63,11 +63,7 @@ strcmp: cmpcs r2, r3 beq 1b sub r0, r2, r3 -#if defined(__USE_BX__) - bx lr -#else - mov pc, lr -#endif + BX(lr) #endif
.size strcmp,.-strcmp diff --git a/libc/string/arm/strlen.S b/libc/string/arm/strlen.S index 0e7737e..9995d76 100644 --- a/libc/string/arm/strlen.S +++ b/libc/string/arm/strlen.S @@ -18,7 +18,6 @@
#include <features.h> #include <endian.h> -#include <sys/syscall.h> #include <bits/arm_asm.h> #include <bits/arm_bx.h>
@@ -99,11 +98,7 @@ Llastword: @ drop through to here once we find a IT(t, ne) addne r0, r0, $1 @ must be zero) #endif -#if defined(__USE_BX__) - bx lr -#else - mov pc,lr -#endif + BX(lr) #endif
.size strlen,.-strlen diff --git a/libc/sysdeps/linux/Makefile.commonarch b/libc/sysdeps/linux/Makefile.commonarch index 1bf2dc5..f8dc17d 100644 --- a/libc/sysdeps/linux/Makefile.commonarch +++ b/libc/sysdeps/linux/Makefile.commonarch @@ -15,7 +15,6 @@ ARCH_SOBJ = $(patsubst %.s,%.o,$(patsubst %.S,%.o,$(addprefix $(ARCH_OUT)/,$(SSR
ARCH_OBJS-y = $(ARCH_COBJ) $(ARCH_SOBJ)
-crt-y := FORCE libc-y += $(ARCH_OBJS-y) libc-nomulti-y += $(ARCH_SOBJ) objclean-y += CLEAN_$(subst $(top_builddir),,$(ARCH_OUT)) @@ -47,16 +46,13 @@ HEADERCLEAN_$(subst $(top_builddir),,$(ARCH_OUT)): $(do_rm) $(ARCH_HEADERS_OUT) endif
-CFLAGS-ucontext_i.c = -S - -$(ARCH_OUT)/ucontext_i.c: $(ARCH_DIR)/ucontext_i.sym - $(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@ - -$(ARCH_OUT)/ucontext_i.s: $(ARCH_OUT)/ucontext_i.c - $(compile.c) - -$(ARCH_OUT)/ucontext_i.h: $(ARCH_OUT)/ucontext_i.s - $(do_sed) $(PTHREAD_GENERATE_MANGLE) $< > $@ +$(ARCH_OUT)/ucontext_i.h: $(top_srcdir)extra/scripts/gen-as-const.awk +$(ARCH_OUT)/ucontext_i.h: $(ARCH_OUT)/ucontext_i.sym + @$(disp_gen) + $(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< \ + | $(CC) $(CFLAGS) -x c - -S -o - \ + | $(SED) $(PTHREAD_GENERATE_MANGLE) > $@ + @if test ! -s $@ ; then rm -f $@ ; false ; fi
pregen-headers-$(UCLIBC_HAS_CONTEXT_FUNCS) += $(ARCH_OUT)/ucontext_i.h
diff --git a/libc/sysdeps/linux/alpha/bits/siginfo.h b/libc/sysdeps/linux/alpha/bits/siginfo.h index 0a37ad0..7e476aa 100644 --- a/libc/sysdeps/linux/alpha/bits/siginfo.h +++ b/libc/sysdeps/linux/alpha/bits/siginfo.h @@ -97,6 +97,14 @@ typedef struct siginfo int si_band; /* Band event for SIGPOLL. */ int si_fd; } _sigpoll; + + /* SIGSYS. */ + struct + { + void *_call_addr; /* Calling user insn. */ + int _syscall; /* Triggering system call number. */ + unsigned int _arch; /* AUDIT_ARCH_* of syscall. */ + } _sigsys; } _sifields; } siginfo_t;
@@ -115,6 +123,9 @@ typedef struct siginfo # define si_addr _sifields._sigfault.si_addr # define si_band _sifields._sigpoll.si_band # define si_fd _sifields._sigpoll.si_fd +# define si_call_addr _sifields._sigsys._call_addr +# define si_syscall _sifields._sigsys._syscall +# define si_arch _sifields._sigsys._arch
/* Values for `si_code'. Positive values are reserved for kernel-generated diff --git a/libc/sysdeps/linux/arm/__longjmp.S b/libc/sysdeps/linux/arm/__longjmp.S index 853b906..58ae8ab 100644 --- a/libc/sysdeps/linux/arm/__longjmp.S +++ b/libc/sysdeps/linux/arm/__longjmp.S @@ -98,12 +98,7 @@ __longjmp: ldcl p1, cr14, [r12], #8 ldcl p1, cr15, [r12], #8 #endif - -#if defined(__USE_BX__) - bx lr -#else - mov pc, lr -#endif + BX(lr) #endif
.size __longjmp,.-__longjmp diff --git a/libc/sysdeps/linux/arm/bits/arm_asm.h b/libc/sysdeps/linux/arm/bits/arm_asm.h index 04664b3..898a78b 100644 --- a/libc/sysdeps/linux/arm/bits/arm_asm.h +++ b/libc/sysdeps/linux/arm/bits/arm_asm.h @@ -13,12 +13,12 @@ unified assembly syntax. */ #define IT(t, cond) /* Code to return from a thumb function stub. */ -#ifdef __ARM_ARCH_4T__ -#define POP_RET pop {r2, pc} -#else -#define POP_RET pop {r2, r3}; bx r3 -#endif -#endif +# if defined __ARM_ARCH_4T__ && defined __THUMB_INTERWORK__ +# define POP_RET pop {r2, r3}; bx r3 +# else +# define POP_RET pop {r2, pc} +# endif +#endif /* __thumb2__ */
#if defined(__ARM_ARCH_6M__) /* Force arm mode to flush out errors on M profile cores. */ diff --git a/libc/sysdeps/linux/arm/bits/arm_bx.h b/libc/sysdeps/linux/arm/bits/arm_bx.h index 321490e..2c29089 100644 --- a/libc/sysdeps/linux/arm/bits/arm_bx.h +++ b/libc/sysdeps/linux/arm/bits/arm_bx.h @@ -24,11 +24,17 @@ #endif /* features.h not yet included */
#if defined(__USE_BX__) -# if ( defined (__ARM_ARCH_2__) || defined (__ARM_ARCH_3__) \ - || defined (__ARM_ARCH_3M__) || defined (__ARM_ARCH_4__) \ - ) +# if (__ARM_ARCH <= 4 && !defined __ARM_ARCH_4T__) # error Use of BX was requested, but is not available on the target processor. # endif /* ARCH level */ #endif /* __USE_BX__ */
+#if defined(__USE_BX__) && (__ARM_ARCH > 4 || (__ARM_ARCH == 4 && defined __ARM_ARCH_4T__)) +# define BX(reg) bx reg +# define BXC(cond, reg) bx##cond reg +#else +# define BX(reg) mov pc, reg +# define BXC(cond, reg) mov##cond pc, reg +#endif + #endif /* _ARM_BX_H */ diff --git a/libc/sysdeps/linux/arm/bits/syscalls.h b/libc/sysdeps/linux/arm/bits/syscalls.h index 778cc34..e447a7b 100644 --- a/libc/sysdeps/linux/arm/bits/syscalls.h +++ b/libc/sysdeps/linux/arm/bits/syscalls.h @@ -53,15 +53,15 @@ { \ int _sys_buf[2]; \ register int __a1 __asm__ ("a1"); \ - register int *_v3 __asm__ ("v3") = _sys_buf; \ - *_v3 = (int) (name); \ + register int *__v3 __asm__ ("v3") = _sys_buf; \ + *__v3 = (int) (name); \ LOAD_ARGS_##nr (args) \ __asm__ __volatile__ ("str r7, [v3, #4]\n" \ "\tldr r7, [v3]\n" \ "\tswi 0 @ syscall " #name "\n" \ "\tldr r7, [v3, #4]" \ : "=r" (__a1) \ - : "r" (_v3) ASM_ARGS_##nr \ + : "r" (__v3) ASM_ARGS_##nr \ : "memory"); \ __internal_sys_result = __a1; \ } \ @@ -111,23 +111,22 @@ register int __a4 __asm__ ("a4") = __a4tmp; #define ASM_ARGS_4 ASM_ARGS_3, "r" (__a4) #define LOAD_ARGS_5(a1, a2, a3, a4, a5) \ - int _v1tmp = (int) (a5); \ + int __v1tmp = (int) (a5); \ LOAD_ARGS_4 (a1, a2, a3, a4) \ - register int _v1 __asm__ ("v1") = _v1tmp; -#define ASM_ARGS_5 ASM_ARGS_4, "r" (_v1) + register int __v1 __asm__ ("v1") = __v1tmp; +#define ASM_ARGS_5 ASM_ARGS_4, "r" (__v1) #define LOAD_ARGS_6(a1, a2, a3, a4, a5, a6) \ - int _v2tmp = (int) (a6); \ + int __v2tmp = (int) (a6); \ LOAD_ARGS_5 (a1, a2, a3, a4, a5) \ - register int _v2 __asm__ ("v2") = _v2tmp; -#define ASM_ARGS_6 ASM_ARGS_5, "r" (_v2) + register int __v2 __asm__ ("v2") = __v2tmp; +#define ASM_ARGS_6 ASM_ARGS_5, "r" (__v2) #ifndef __thumb__ #define LOAD_ARGS_7(a1, a2, a3, a4, a5, a6, a7) \ - int _v3tmp = (int) (a7); \ + int __v3tmp = (int) (a7); \ LOAD_ARGS_6 (a1, a2, a3, a4, a5, a6) \ - register int _v3 __asm__ ("v3") = _v3tmp; -#define ASM_ARGS_7 ASM_ARGS_6, "r" (_v3) + register int __v3 __asm__ ("v3") = __v3tmp; +#define ASM_ARGS_7 ASM_ARGS_6, "r" (__v3) #endif
- #endif /* __ASSEMBLER__ */ #endif /* _BITS_SYSCALLS_H */ diff --git a/libc/sysdeps/linux/arm/bits/uClibc_arch_features.h b/libc/sysdeps/linux/arm/bits/uClibc_arch_features.h index b01d79c..e85aa52 100644 --- a/libc/sysdeps/linux/arm/bits/uClibc_arch_features.h +++ b/libc/sysdeps/linux/arm/bits/uClibc_arch_features.h @@ -48,6 +48,32 @@ /* only weird assemblers generally need this */ #undef __UCLIBC_ASM_LINE_SEP__
+ +/* The __ARM_ARCH define is provided by gcc 4.8. Construct it otherwise. */ +#ifndef __ARM_ARCH +# ifdef __ARM_ARCH_2__ +# define __ARM_ARCH 2 +# elif defined (__ARM_ARCH_3__) || defined (__ARM_ARCH_3M__) +# define __ARM_ARCH 3 +# elif defined (__ARM_ARCH_4__) || defined (__ARM_ARCH_4T__) +# define __ARM_ARCH 4 +# elif defined (__ARM_ARCH_5__) || defined (__ARM_ARCH_5E__) \ + || defined(__ARM_ARCH_5T__) || defined(__ARM_ARCH_5TE__) \ + || defined(__ARM_ARCH_5TEJ__) +# define __ARM_ARCH 5 +# elif defined (__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \ + || defined (__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) \ + || defined (__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) +# define __ARM_ARCH 6 +# elif defined (__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) \ + || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) \ + || defined(__ARM_ARCH_7EM__) +# define __ARM_ARCH 7 +# else +# error unknown arm architecture +# endif +#endif + #ifdef __GNUC__ # define __need_uClibc_config_h # include <bits/uClibc_config.h> diff --git a/libc/sysdeps/linux/arm/clone.S b/libc/sysdeps/linux/arm/clone.S index 51eda5f..6a89517 100644 --- a/libc/sysdeps/linux/arm/clone.S +++ b/libc/sysdeps/linux/arm/clone.S @@ -128,11 +128,8 @@ __clone: beq 1f pop {r4, r7} blt __error -#if defined(__USE_BX__) - bxne lr -#else - movne pc, lr -#endif + IT(t, ne) + BXC(ne, lr)
cfi_startproc .fnend diff --git a/libc/sysdeps/linux/arm/mmap64.S b/libc/sysdeps/linux/arm/mmap64.S index f4c491a..c9f2bd2 100644 --- a/libc/sysdeps/linux/arm/mmap64.S +++ b/libc/sysdeps/linux/arm/mmap64.S @@ -92,11 +92,7 @@ mmap64: cmn r0, $4096 ldmfd sp!, {r4, r5} IT(t, cc) -#if defined(__USE_BX__) - bxcc lr -#else - movcc pc, lr -#endif + BXC(cc, lr) b __syscall_error .Linval: mov r0, $-EINVAL diff --git a/libc/sysdeps/linux/arm/syscall-eabi.S b/libc/sysdeps/linux/arm/syscall-eabi.S index 005cfe3..534c6e9 100644 --- a/libc/sysdeps/linux/arm/syscall-eabi.S +++ b/libc/sysdeps/linux/arm/syscall-eabi.S @@ -15,7 +15,7 @@ License along with the GNU C Library; if not, see http://www.gnu.org/licenses/. */
-#include <sys/syscall.h> +#include <features.h> #include <bits/arm_asm.h> #include <bits/arm_bx.h>
@@ -62,11 +62,7 @@ syscall: ldmfd sp!, {r4, r5, r6, r7} cmn r0, #4096 IT(t, cc) -#if defined(__USE_BX__) - bxcc lr -#else - movcc pc, lr -#endif + BXC(cc, lr) b __syscall_error #endif
diff --git a/libc/sysdeps/linux/arm/sysdep.h b/libc/sysdeps/linux/arm/sysdep.h index 2d0a9cc..7f1e9c1 100644 --- a/libc/sysdeps/linux/arm/sysdep.h +++ b/libc/sysdeps/linux/arm/sysdep.h @@ -21,7 +21,6 @@
#include <common/sysdep.h> #include <bits/arm_bx.h> - #include <sys/syscall.h> /* For Linux we can use the system call table in the header file /usr/include/asm/unistd.h @@ -50,17 +49,10 @@ #ifdef __APCS_32__ #define LOADREGS(cond, base, reglist...)\ ldm##cond base,reglist -#ifdef __USE_BX__ -#define RETINSTR(cond, reg) \ - bx##cond reg -#define DO_RET(_reg) \ - bx _reg -#else -#define RETINSTR(cond, reg) \ - mov##cond pc, reg +#define RETINSTR(cond, reg) \ + BXC(cond, reg) #define DO_RET(_reg) \ - mov pc, _reg -#endif + BX(_reg) #else /* APCS-26 */ #define LOADREGS(cond, base, reglist...) \ ldm##cond base,reglist^ diff --git a/libc/sysdeps/linux/arm/vfork.S b/libc/sysdeps/linux/arm/vfork.S index 99fb6cb..221a90c 100644 --- a/libc/sysdeps/linux/arm/vfork.S +++ b/libc/sysdeps/linux/arm/vfork.S @@ -74,11 +74,7 @@ __vfork: RESTORE_PID cmn r0, #4096 IT(t, cc) -#if defined(__USE_BX__) - bxcc lr -#else - movcc pc, lr -#endif + BXC(cc, lr)
/* Check if vfork even exists. */ ldr r1, =-ENOSYS @@ -92,11 +88,7 @@ __vfork:
/* Syscall worked. Return to child/parent */ IT(t, cc) -#if defined(__USE_BX__) - bxcc lr -#else - movcc pc, lr -#endif + BXC(cc, lr)
__error: b __syscall_error diff --git a/libc/sysdeps/linux/common/bits/siginfo.h b/libc/sysdeps/linux/common/bits/siginfo.h index c26e066..724f756 100644 --- a/libc/sysdeps/linux/common/bits/siginfo.h +++ b/libc/sysdeps/linux/common/bits/siginfo.h @@ -103,6 +103,14 @@ typedef struct siginfo long int si_band; /* Band event for SIGPOLL. */ int si_fd; } _sigpoll; + + /* SIGSYS. */ + struct + { + void *_call_addr; /* Calling user insn. */ + int _syscall; /* Triggering system call number. */ + unsigned int _arch; /* AUDIT_ARCH_* of syscall. */ + } _sigsys; } _sifields; } siginfo_t;
@@ -121,6 +129,9 @@ typedef struct siginfo # define si_addr _sifields._sigfault.si_addr # define si_band _sifields._sigpoll.si_band # define si_fd _sifields._sigpoll.si_fd +# define si_call_addr _sifields._sigsys._call_addr +# define si_syscall _sifields._sigsys._syscall +# define si_arch _sifields._sigsys._arch
/* Values for `si_code'. Positive values are reserved for kernel-generated diff --git a/libc/sysdeps/linux/h8300/Makefile b/libc/sysdeps/linux/h8300/Makefile index 2ab4ee6..5524623 100644 --- a/libc/sysdeps/linux/h8300/Makefile +++ b/libc/sysdeps/linux/h8300/Makefile @@ -1,65 +1,13 @@ # Makefile for uClibc # -# Copyright (C) 2000-2006 Erik Andersen andersen@uclibc.org +# Copyright (C) 2015 Yoshinori Sato +# +# Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball. # -# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. - -TOPDIR=../../../../ -include $(TOPDIR)Rules.mak -ifeq ($(DOPIC),y) -# is this not provided by gcc ? -ASFLAGS+=-D__PIC__ -endif - -#FIXME -- this arch should include its own crti.S and crtn.S -UCLIBC_CTOR_DTOR=n - -CRT_SRC := crt0.S -CRT_OBJ := crt0.o crt1.o -CTOR_TARGETS := $(TOPDIR)lib/crti.o $(TOPDIR)lib/crtn.o - -SSRC := __longjmp.S bsd-_setjmp.S bsd-setjmp.S clone.S setjmp.S vfork.S -SOBJ := $(patsubst %.S,%.o, $(SSRC)) - -CSRC := ptrace.c brk.c -COBJ := $(patsubst %.c,%.o, $(CSRC)) - -OBJS := $(SOBJ) $(COBJ) - -OBJ_LIST := ../../../obj.sysdeps.$(TARGET_ARCH) - -all: $(OBJ_LIST) $(CTOR_TARGETS) - -$(OBJ_LIST): $(OBJS) $(CRT_OBJ) - $(STRIPTOOL) -x -R .note -R .comment $^ - $(INSTALL) -d $(TOPDIR)lib/ - cp $(CRT_OBJ) $(TOPDIR)lib/ - echo $(patsubst %, sysdeps/linux/$(TARGET_ARCH)/%, $(OBJS)) > $@ - -$(CRT_OBJ): $(CRT_SRC) - $(CC) $(ASFLAGS) -DL_$* $< -c -o $*.o - -$(SOBJ): %.o : %.S - $(CC) $(ASFLAGS) -c $< -o $@ - -$(COBJ): %.o : %.c - $(CC) $(CFLAGS) -c $< -o $@ - -ifeq ($(UCLIBC_CTOR_DTOR),y) -$(TOPDIR)lib/crti.o: crti.S - $(INSTALL) -d $(TOPDIR)lib/ - $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c $< -o $@ - -$(TOPDIR)lib/crtn.o: crtn.S - $(INSTALL) -d $(TOPDIR)lib/ - $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c $< -o $@ -else -$(CTOR_TARGETS): - $(INSTALL) -d $(TOPDIR)lib/ - $(AR) $(ARFLAGS) $@ -endif - -headers:
-clean: - $(RM) *.o *~ core +top_srcdir=../../../../ +top_builddir=../../../../ +all: objs +include $(top_builddir)Rules.mak +include Makefile.arch +include $(top_srcdir)Makerules diff --git a/libc/sysdeps/linux/h8300/Makefile.arch b/libc/sysdeps/linux/h8300/Makefile.arch new file mode 100644 index 0000000..371d3dd --- /dev/null +++ b/libc/sysdeps/linux/h8300/Makefile.arch @@ -0,0 +1,10 @@ +# Makefile for uClibc +# +# Copyright (C) 2015 Yoshinori Sato +# +# Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball. +# + +CSRC-y := brk.c ptrace.c + +SSRC-y := __longjmp.S bsd-_setjmp.S bsd-setjmp.S clone.S setjmp.S vfork.S diff --git a/libc/sysdeps/linux/h8300/__longjmp.S b/libc/sysdeps/linux/h8300/__longjmp.S index eb433df..bcb0985 100644 --- a/libc/sysdeps/linux/h8300/__longjmp.S +++ b/libc/sysdeps/linux/h8300/__longjmp.S @@ -4,10 +4,10 @@ .h8300h #endif .text - -.global ___longjmp
-___longjmp: +.global __longjmp + +__longjmp: mov.l er1,er1 bne 1f sub.l er1,er1 diff --git a/libc/sysdeps/linux/h8300/bits/byteswap.h b/libc/sysdeps/linux/h8300/bits/byteswap.h index 71a66c6..08ca99f 100644 --- a/libc/sysdeps/linux/h8300/bits/byteswap.h +++ b/libc/sysdeps/linux/h8300/bits/byteswap.h @@ -19,20 +19,7 @@ #ifndef _ASM_BITS_BYTESWAP_H #define _ASM_BITS_BYTESWAP_H 1
-#define __bswap_non_constant_32(x) \ - __extension__ \ - ({ unsigned int __v; \ - __asm__ __volatile__ ("mov.l %0,er0\n\t" \ - "mov.b r0l,r1h\n\t" \ - "mov.b r0h,r1l\n\t" \ - "mov.w r1,e1\n\t" \ - "mov.w e0,r0\n\t" \ - "mov.b r0l,r1h\n\t" \ - "mov.b r0h,r1l\n\t" \ - "mov.l er1,%0" \ - : "=d" (__v) \ - : "0" (x): "er0","er1"); \ - __v; }) +#define __bswap_non_constant_32(x) __builtin_bswap32(x)
#endif
diff --git a/libc/sysdeps/linux/h8300/bits/fcntl.h b/libc/sysdeps/linux/h8300/bits/fcntl.h index 45deec4..1c653be 100644 --- a/libc/sysdeps/linux/h8300/bits/fcntl.h +++ b/libc/sysdeps/linux/h8300/bits/fcntl.h @@ -22,6 +22,9 @@
#include <sys/types.h> +#ifdef __USE_GNU +# include <bits/uio.h> +#endif
/* open/fcntl - O_SYNC is only implemented on blocks devices and on files located on an ext2 file system */ @@ -42,8 +45,10 @@
#ifdef __USE_GNU # define O_DIRECTORY 040000 /* Must be a directory. */ -# define O_NOFOLLOW 0100000 /* Do not follow links. */ # define O_DIRECT 0200000 /* Direct disk access. */ +# define O_NOFOLLOW 0400000 /* Do not follow links. */ +# define O_NOATIME 01000000 /* Do not set atime. */ +# define O_CLOEXEC 02000000 /* Set close_on_exec. */ #endif
/* For now Linux has synchronisity options for data and read operations. diff --git a/libc/sysdeps/linux/h8300/bits/kernel_stat.h b/libc/sysdeps/linux/h8300/bits/kernel_stat.h deleted file mode 100644 index 5f6c8ae..0000000 --- a/libc/sysdeps/linux/h8300/bits/kernel_stat.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef _BITS_STAT_STRUCT_H -#define _BITS_STAT_STRUCT_H - -/* This file provides whatever this particular arch's kernel thinks - * struct kernel_stat should look like... It turns out each arch has a - * different opinion on the subject... */ - -struct kernel_stat { - unsigned short st_dev; - unsigned short __pad1; - unsigned long st_ino; - unsigned short st_mode; - unsigned short st_nlink; - unsigned short st_uid; - unsigned short st_gid; - unsigned short st_rdev; - unsigned short __pad2; - unsigned long st_size; - unsigned long st_blksize; - unsigned long st_blocks; - struct timespec st_atim; - struct timespec st_mtim; - struct timespec st_ctim; - unsigned long __unused4; - unsigned long __unused5; -}; - -struct kernel_stat64 { - unsigned long long st_dev; - unsigned char __pad1[2]; -#define _HAVE_STAT64___ST_INO - unsigned long __st_ino; - unsigned int st_mode; - unsigned int st_nlink; - unsigned long st_uid; - unsigned long st_gid; - unsigned short st_rdev; - unsigned char __pad3[10]; - long long st_size; - unsigned long st_blksize; - unsigned long st_blocks; /* Number 512-byte blocks allocated. */ - unsigned long __pad4; /* future possible st_blocks high bits */ - struct timespec st_atim; - struct timespec st_mtim; - struct timespec st_ctim; - unsigned long long st_ino; -}; - -#endif /* _BITS_STAT_STRUCT_H */ - diff --git a/libc/sysdeps/linux/h8300/bits/kernel_types.h b/libc/sysdeps/linux/h8300/bits/kernel_types.h index 4cfd1bf..7e76891 100644 --- a/libc/sysdeps/linux/h8300/bits/kernel_types.h +++ b/libc/sysdeps/linux/h8300/bits/kernel_types.h @@ -35,6 +35,18 @@ typedef __kernel_dev_t __kernel_old_dev_t; typedef long __kernel_long_t; typedef unsigned long __kernel_ulong_t;
+#define __kernel_long_t __kernel_long_t +#define __kernel_ino_t __kernel_ino_t +#define __kernel_mode_t __kernel_mode_t +#define __kernel_pid_t __kernel_pid_t +#define __kernel_ipc_pid_t __kernel_ipc_pid_t +#define __kernel_uid_t __kernel_uid_t +#define __kernel_susecond_t __kernel_susecond_t +#define __kernel_daddr_t __kernel_daddr_t +#define __kernel_uid32_t __kernel_uid32_t +#define __kernel_old_uid_t __kernel_old_uid_t +#define __kernel_old_dev_t __kernel_old_dev_t + typedef struct { #ifdef __USE_ALL int val[2]; @@ -42,5 +54,6 @@ typedef struct { int __val[2]; #endif } __kernel_fsid_t; +#define __kernel_fsid_t __kernel_fsid_t
#endif /* _BITS_KERNEL_TYPES_H */ diff --git a/libc/sysdeps/linux/h8300/bits/syscalls.h b/libc/sysdeps/linux/h8300/bits/syscalls.h index 5867ed6..b43795f 100644 --- a/libc/sysdeps/linux/h8300/bits/syscalls.h +++ b/libc/sysdeps/linux/h8300/bits/syscalls.h @@ -1,151 +1,85 @@ -/* Unlike the asm/unistd.h kernel header file (which this is partly based on), - * this file must be able to cope with PIC and non-PIC code. For some arches - * there is no difference. For x86 (which has far too few registers) there is - * a difference. Regardless, including asm/unistd.h is hereby officially - * forbidden. Don't do it. It is bad for you. - */ +#ifndef _BITS_SYSCALLS_H +#define _BITS_SYSCALLS_H #ifndef _SYSCALL_H # error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead." #endif
-#define __syscall_return(type, res) \ -do { \ - if ((unsigned long)(res) >= (unsigned long)(-125)) { \ - /* avoid using res which is declared to be in register d0; \ - errno might expand to a function call and clobber it. */ \ - int __err = -(res); \ - errno = __err; \ - res = -1; \ - } \ - return (type) (res); \ -} while (0) +#ifndef __ASSEMBLER__
-#define _syscall0(type, name) \ -type name(void) \ -{ \ - register long __res __asm__("er0"); \ - __asm__ __volatile__ ("mov.l %1,er0\n\t" \ - "trapa #0\n\t" \ - : "=r" (__res) \ - : "ir" (__NR_##name) \ - : "cc"); \ - if ((unsigned long)(__res) >= (unsigned long)(-125)) { \ - errno = -__res; \ - __res = -1; \ - } \ - return (type)__res; \ -} +#include <errno.h>
-#define _syscall1(type, name, atype, a) \ -type name(atype a) \ -{ \ - register long __res __asm__("er0"); \ - __asm__ __volatile__ ("mov.l %2, er1\n\t" \ - "mov.l %1, er0\n\t" \ - "trapa #0\n\t" \ - : "=r" (__res) \ - : "ir" (__NR_##name), \ - "g" ((long)a) \ - : "cc", "er1"); \ - if ((unsigned long)(__res) >= (unsigned long)(-125)) { \ - errno = -__res; \ - __res = -1; \ - } \ - return (type)__res; \ -} +#define ASMFMT_0 +#define ASMFMT_1 , "g"(er1) +#define ASMFMT_2 , "g"(er1), "g"(er2) +#define ASMFMT_3 , "g"(er1), "g"(er2), "g"(er3) +#define ASMFMT_4 , "g"(er1), "g"(er2), "g"(er3), "g"(er4) +#define ASMFMT_5 , "g"(er1), "g"(er2), "g"(er3), "g"(er4), "g"(er5) +#define ASMFMT_6 , "g"(er1), "g"(er2), "g"(er3), "g"(er4), "m"(er5), "m"(er6)
-#define _syscall2(type, name, atype, a, btype, b) \ -type name(atype a, btype b) \ -{ \ - register long __res __asm__("er0"); \ - __asm__ __volatile__ ("mov.l %3, er2\n\t" \ - "mov.l %2, er1\n\t" \ - "mov.l %1, er0\n\t" \ - "trapa #0\n\t" \ - : "=r" (__res) \ - : "ir" (__NR_##name), \ - "g" ((long)a), \ - "g" ((long)b) \ - : "cc", "er1", "er2"); \ - if ((unsigned long)(__res) >= (unsigned long)(-125)) { \ - errno = -__res; \ - __res = -1; \ - } \ - return (type)__res; \ -} +#define SUBSTITUTE_ARGS_0() do {} while(0); +#define SUBSTITUTE_ARGS_1(arg1) \ + register long int er1 __asm__("er1") = (long int)arg1; +#define SUBSTITUTE_ARGS_2(arg1, arg2) \ + register long int er1 __asm__("er1") = (long int)arg1; \ + register long int er2 __asm__("er2") = (long int)arg2; +#define SUBSTITUTE_ARGS_3(arg1, arg2, arg3) \ + register long int er1 __asm__("er1") = (long int)arg1; \ + register long int er2 __asm__("er2") = (long int)arg2; \ + register long int er3 __asm__("er3") = (long int)arg3; +#define SUBSTITUTE_ARGS_4(arg1, arg2, arg3, arg4) \ + register long int er1 __asm__("er1") = (long int)arg1; \ + register long int er2 __asm__("er2") = (long int)arg2; \ + register long int er3 __asm__("er3") = (long int)arg3; \ + register long int er4 __asm__("er4") = (long int)arg4; +#define SUBSTITUTE_ARGS_5(arg1, arg2, arg3, arg4, arg5) \ + register long int er1 __asm__("er1") = (long int)arg1; \ + register long int er2 __asm__("er2") = (long int)arg2; \ + register long int er3 __asm__("er3") = (long int)arg3; \ + register long int er4 __asm__("er4") = (long int)arg4; \ + register long int er5 __asm__("er5") = (long int)arg5; +#define SUBSTITUTE_ARGS_6(arg1, arg2, arg3, arg4, arg5, arg6) \ + register long int er1 __asm__("er1") = (long int)arg1; \ + register long int er2 __asm__("er2") = (long int)arg2; \ + register long int er3 __asm__("er3") = (long int)arg3; \ + register long int er4 __asm__("er4") = (long int)arg4; \ + long int er5 = (long int)arg5; \ + long int er6 = (long int)arg6;
-#define _syscall3(type, name, atype, a, btype, b, ctype, c) \ -type name(atype a, btype b, ctype c) \ -{ \ - register long __res __asm__("er0"); \ - __asm__ __volatile__ ("mov.l %4, er3\n\t" \ - "mov.l %3, er2\n\t" \ - "mov.l %2, er1\n\t" \ - "mov.l %1, er0\n\t" \ - "trapa #0\n\t" \ - : "=r" (__res) \ - : "ir" (__NR_##name), \ - "g" ((long)a), \ - "g" ((long)b), \ - "g" ((long)c) \ - : "cc", "er1", "er2", "er3"); \ - if ((unsigned long)(__res) >= (unsigned long)(-125)) { \ - errno = -__res; \ - __res = -1; \ - } \ - return (type)__res; \ -} +#define LOAD_ARGS_0 +#define LOAD_ARGS_1 +#define LOAD_ARGS_2 +#define LOAD_ARGS_3 +#define LOAD_ARGS_4 +#define LOAD_ARGS_5 +#define LOAD_ARGS_6 "mov.l er5,@-sp\n\tmov.l %6,er5\n\t" \ + "mov.l er6,@-sp\n\tmov.l %7,er6\n\t"
-#define _syscall4(type, name, atype, a, btype, b, ctype, c, dtype, d) \ -type name(atype a, btype b, ctype c, dtype d) \ -{ \ - register long __res __asm__("er0"); \ - __asm__ __volatile__ ("mov.l %5, er4\n\t" \ - "mov.l %4, er3\n\t" \ - "mov.l %3, er2\n\t" \ - "mov.l %2, er1\n\t" \ - "mov.l %1, er0\n\t" \ - "trapa #0\n\t" \ - : "=r" (__res) \ - : "ir" (__NR_##name), \ - "g" ((long)a), \ - "g" ((long)b), \ - "g" ((long)c), \ - "g" ((long)d) \ - : "cc", "er1", "er2", "er3", "er4"); \ - if ((unsigned long)(__res) >= (unsigned long)(-125)) { \ - errno = -__res; \ - __res = -1; \ - } \ - return (type)__res; \ -} +#define RESTORE_ARGS_0 +#define RESTORE_ARGS_1 +#define RESTORE_ARGS_2 +#define RESTORE_ARGS_3 +#define RESTORE_ARGS_4 +#define RESTORE_ARGS_5 +#define RESTORE_ARGS_6 "mov.l @sp+,er6\n\tmov.l @sp+,er5"
-#define _syscall5(type, name, atype, a, btype, b, ctype, c, dtype, d, etype, e) \ -type name(atype a, btype b, ctype c, dtype d, etype e) \ -{ \ - register long __res __asm__("er0"); \ - __asm__ __volatile__ ( \ - "mov.l er5,@-sp\n\t" \ - "mov.l %5, er4\n\t" \ - "mov.l %4, er3\n\t" \ - "mov.l %3, er2\n\t" \ - "mov.l %2, er1\n\t" \ - "mov.l %1, er0\n\t" \ - "mov.l %6, er5\n\t" \ - "trapa #0\n\t" \ - "mov.l @sp+,er5\n\t" \ - : "=r" (__res) \ - : "ir" (__NR_##name), \ - "g" ((long)a), \ - "g" ((long)b), \ - "g" ((long)c), \ - "g" ((long)d), \ - "m" ((long)e) \ - : "cc", "er1", "er2", "er3", "er4"); \ - if ((unsigned long)(__res) >= (unsigned long)(-125)) { \ - errno = -__res; \ - __res = -1; \ - } \ - return (type)__res; \ -} +/* The _NCS variant allows non-constant syscall numbers. */ +#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \ +(__extension__ \ + ({ \ + register long int er0 __asm__ ("er0"); \ + SUBSTITUTE_ARGS_##nr(args) \ + __asm__ __volatile__ ( \ + LOAD_ARGS_##nr \ + "mov.l %1,er0\n\t" \ + "trapa #0\n\t" \ + RESTORE_ARGS_##nr \ + : "=r" (er0) \ + : "ir" (name) ASMFMT_##nr \ + : "memory" \ + ); \ + (int) er0; \ + }) \ +)
+#endif /* __ASSEMBLER__ */ +#endif /* _BITS_SYSCALLS_H */ diff --git a/libc/sysdeps/linux/h8300/bits/uClibc_arch_features.h b/libc/sysdeps/linux/h8300/bits/uClibc_arch_features.h index b76b861..fb430ae 100644 --- a/libc/sysdeps/linux/h8300/bits/uClibc_arch_features.h +++ b/libc/sysdeps/linux/h8300/bits/uClibc_arch_features.h @@ -43,6 +43,6 @@ #define __UCLIBC_HAVE_SIGNED_ZERO__
/* only weird assemblers generally need this */ -#undef __UCLIBC_ASM_LINE_SEP__ +#define __UCLIBC_ASM_LINE_SEP__ !
#endif /* _BITS_UCLIBC_ARCH_FEATURES_H */ diff --git a/libc/sysdeps/linux/h8300/bsd-_setjmp.S b/libc/sysdeps/linux/h8300/bsd-_setjmp.S index fbe7025..766d9cc 100644 --- a/libc/sysdeps/linux/h8300/bsd-_setjmp.S +++ b/libc/sysdeps/linux/h8300/bsd-_setjmp.S @@ -1,4 +1,4 @@ -/* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'. H8/300 version. */ +/* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'. H8/300 version. */
#include <jmpbuf-offsets.h>
@@ -8,10 +8,10 @@ .h8300h #endif .text - -.global __setjmp
-__setjmp: +.global _setjmp + +_setjmp: add.l #JB_SIZE,er0 mov.l @sp,er1 ; return PC mov.l er1,@-er0 @@ -23,3 +23,5 @@ __setjmp: sub.l er0,er0 mov.l er0,@(JB_SIZE:16,er1) rts + + .end diff --git a/libc/sysdeps/linux/h8300/bsd-setjmp.S b/libc/sysdeps/linux/h8300/bsd-setjmp.S index 74ebb8f..77c810f 100644 --- a/libc/sysdeps/linux/h8300/bsd-setjmp.S +++ b/libc/sysdeps/linux/h8300/bsd-setjmp.S @@ -1,4 +1,4 @@ -/* BSD `_setjmp' entry point to `sigsetjmp (..., 1)'. H8/300 version. */ +/* BSD `_setjmp' entry point to `sigsetjmp (..., 1)'. H8/300 version. */
#include <jmpbuf-offsets.h>
@@ -8,10 +8,10 @@ .h8300h #endif .text - -.global _setjmp
-_setjmp: +.global setjmp + +setjmp: add.l #JB_SIZE,er0 mov.l @sp,er1 ; return PC mov.l er1,@-er0 @@ -21,8 +21,9 @@ _setjmp: mov.l er4,@-er0 sub.l er0,er0 #if !defined(__PIC__) - jmp @___sigjmp_save + jmp @__sigjmp_save #else - mov.l @(___sigjmp_save@GOTOFF,er5),er1 + mov.l @(__sigjmp_save@GOTOFF,er5),er1 jmp @er3 #endif + .end diff --git a/libc/sysdeps/linux/h8300/clone.S b/libc/sysdeps/linux/h8300/clone.S index 554a297..a00eba4 100644 --- a/libc/sysdeps/linux/h8300/clone.S +++ b/libc/sysdeps/linux/h8300/clone.S @@ -1,5 +1,4 @@ -/* Adapted from glibc */ -/* Copyright (C) 1996, 1997 Free Software Foundation, Inc. */ +/* Copyright 2015 Yoshinori Sato ysato@users.sourceforge.jp */
/* clone is even more special than fork as it mucks with stacks and invokes a function in the right context after its all over. */ @@ -8,7 +7,8 @@ #include <bits/errno.h> #include <sys/syscall.h>
-/* int _clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */ +/* int _clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg + void *parent_tidptr, void *tls, void *child_tidptr) */
#ifdef __H8300H__ .h8300h @@ -18,8 +18,8 @@ #endif
.text -.globl _clone -_clone: +.globl clone +clone: /* Sanity check arguments. */ mov.l #-EINVAL,er3 mov.l er0,er0 /* no NULL function pointers */ @@ -31,13 +31,25 @@ _clone: mov.l @(4:16,sp),er3 mov.l er3,@-er1
- /* Do the system call */ + /* setup argument */ mov.l er0,er3 /* er3 = child entry */ - mov.l er1,er0 - mov.l er2,er1 /* er1 = flags */ - mov.l er0,er2 /* er2 = child sp */ - mov.l #__NR_clone,r0 + sub.l #20,sp + mov.l er2,@sp /* flags */ + mov.l er1,@(4,sp) /* new sp */ + mov.l sp,er1 + mov.l @(20+8,sp),er0 + mov.l er0,@er1 /* parent tid */ + adds #4,er1 + mov.l @(20+16,sp),er0 + mov.l er0,@er1 /* child tid */ + adds #4,er1 + mov.l @(20+12,sp),er0 + mov.l er0,@er1 /* tls */ + /* do the system call */ + mov.l sp,er1 + mov.l #__NR_clone,er0 trapa #0 + add.l #20,sp mov.l er0,er0 bmi __syscall_error beq thread_start @@ -62,7 +74,9 @@ __syscall_error:
thread_start: mov.l @sp+,er0 /* restore args */ - jsr @er3 + jsr @er3 mov.l er0,er1 mov.l #__NR_exit,er0 trapa #0 + + .end diff --git a/libc/sysdeps/linux/h8300/crt0.S b/libc/sysdeps/linux/h8300/crt1.S similarity index 66% rename from libc/sysdeps/linux/h8300/crt0.S rename to libc/sysdeps/linux/h8300/crt1.S index be6768d..847872a 100644 --- a/libc/sysdeps/linux/h8300/crt0.S +++ b/libc/sysdeps/linux/h8300/crt1.S @@ -28,17 +28,39 @@ not, see http://www.gnu.org/licenses/. */ #else .h8300h #endif +/* +void __uClibc_main(int (*main)(int, char **, char **), int argc, + char **argv, void (*app_init)(void), void (*app_fini)(void), + void (*rtld_fini)(void),void *stack_end attribute_unused) +*/ .text
_start: /* put here so that references to _start work with elf-PIC */
- mov.l @(0,sp),er0 /* argc */ - mov.l @(4,sp),er1 /* argv */ - mov.l @(8,sp),er2 /* envp */ + mov.l @sp+,er1 /* argc */ + mov.l @sp+,er2 /* argv */ + add.l #4,sp + #if !defined(__PIC__) - jsr @___uClibc_main + mov.l sp, @-sp + sub.l er0,er0 + mov.l er0,@-sp + mov.l #_fini,er0 + mov.l er0,@-sp + mov.l #_init,er0 + mov.l er0,@-sp + mov.l #main,er0 + jsr @__uClibc_main #else - mov.l @(___uClibc_main@GOTOFF,er5),er3 + mov.l sp, @-sp + sub.l er0,er0 + mov.l er0,@-sp + mov.l @(_fini@GOTOFF,er5),er0 + mov.l er0,@-sp + mov.l @(_init@GOTOFF,er5),er0 + mov.l er0,@-sp + mov.l @(main@GOTOFF,er5),er0 + mov.l @(__uClibc_main@GOTOFF,er5),er3 jsr @er3 #endif
@@ -61,9 +83,9 @@ empty_func:
/* Define a symbol for the first piece of initialized data. */ .data - .globl __data_start -__data_start: + .globl _data_start +_data_start: .long 0 .weak data_start - data_start = __data_start + data_start = _data_start
diff --git a/libc/sysdeps/linux/h8300/crti.S b/libc/sysdeps/linux/h8300/crti.S index 270df27..cc6afe9 100644 --- a/libc/sysdeps/linux/h8300/crti.S +++ b/libc/sysdeps/linux/h8300/crti.S @@ -10,8 +10,8 @@ .section .init ; #NO_APP .align 1 - .global __init -__init: + .global _init +_init: mov.l er6,@-er7 mov.l er7,er6 ; #APP @@ -20,8 +20,8 @@ __init: .section .fini ; #NO_APP .align 1 - .global __fini -__fini: + .global _fini +_fini: mov.l er6,@-er7 mov.l er7,er6 ; #APP diff --git a/libc/sysdeps/linux/h8300/crtn.S b/libc/sysdeps/linux/h8300/crtn.S index 8f9fa1f..a390704 100644 --- a/libc/sysdeps/linux/h8300/crtn.S +++ b/libc/sysdeps/linux/h8300/crtn.S @@ -10,7 +10,7 @@ .section .init ; #NO_APP .align 1 - .global __init + .global _init ; #NO_APP mov.l @er7+,er6 rts @@ -19,7 +19,7 @@ .section .fini ; #NO_APP .align 1 - .global __fini + .global _fini ; #NO_APP mov.l @er7+,er6 rts diff --git a/libc/sysdeps/linux/h8300/setjmp.S b/libc/sysdeps/linux/h8300/setjmp.S index f2795fa..0b8f052 100644 --- a/libc/sysdeps/linux/h8300/setjmp.S +++ b/libc/sysdeps/linux/h8300/setjmp.S @@ -7,9 +7,9 @@ #endif .text
-.global ___sigsetjmp +.global __sigsetjmp
-___sigsetjmp: +__sigsetjmp: add.l #JB_SIZE,er0 mov.l @sp,er1 ; return PC mov.l er1,@-er0 diff --git a/libc/sysdeps/linux/h8300/vfork.S b/libc/sysdeps/linux/h8300/vfork.S index 9b65f4f..1c70dd2 100644 --- a/libc/sysdeps/linux/h8300/vfork.S +++ b/libc/sysdeps/linux/h8300/vfork.S @@ -1,10 +1,7 @@ +/* Copyright 2002, 2015 Yoshinori Sato ysato@users.sourceforge.jp */
#include <sys/syscall.h>
-#ifndef __NR_vfork -#define __NR_vfork __NR_fork /* uClinux-2.0 only has fork which is vfork */ -#endif - #ifdef __H8300S__ .h8300s #else @@ -12,29 +9,60 @@ #endif .text .align 2 - .globl ___vfork - .hidden ___vfork - .type ___vfork,@function -___vfork: + .globl __vfork + .hidden __vfork + .type __vfork,@function +__vfork: +#ifdef __NR_vfork mov.l @sp+, er1 sub.l er0,er0 mov.b #__NR_vfork,r0l trapa #0 + mov.l #-4096, er2 cmp.l er0,er2 bcs fix_errno - jmp @er1 /* don't return, just jmp directly */ + jmp @er1 /* don't return, just jmp directly */ fix_errno: neg.l er0 -#if !defined(__PIC__) +# if !defined(__PIC__) mov.l er0,@_errno -#else +# else mov.l @(_errno@GOTOFF,er5),er2 mov.l er0,@er2 -#endif +# endif sub.l er0,er0 dec.l #1,er0 - jmp @er1 /* don't return, just jmp directly */ + jmp @er1 /* don't return, just jmp directly */ +#else + mov.l @sp+,er2 /* er2 = return address */ + mov.l #vfork_args,er1 + sub.l er0,er0 + mov.b #__NR_clone,r0l + trapa #0 + mov.l #-4096,er1 + cmp.l er0,er1 + bcc done + neg.l er0 +# if !defined(__PIC__) + mov.l er0,@errno +# else + mov.l @(errno@GOTOFF,er5),er1 + mov.l er0,@er1 +# endif + sub.l er0,er0 + dec.l #1,er0 +done: + jmp @er2 + +vfork_args: + .long 0x80004100 /* CLONE_VFORK | CLONE_VM | SIGCHLD */ + .long 0 + .long 0 + .long 0 + .long 0 +#endif
weak_alias(__vfork,vfork) libc_hidden_def(vfork) + .end diff --git a/libc/sysdeps/linux/ia64/bits/siginfo.h b/libc/sysdeps/linux/ia64/bits/siginfo.h index 3ac988b..df18b36 100644 --- a/libc/sysdeps/linux/ia64/bits/siginfo.h +++ b/libc/sysdeps/linux/ia64/bits/siginfo.h @@ -102,6 +102,14 @@ typedef struct siginfo long int si_band; /* Band event for SIGPOLL. */ int si_fd; } _sigpoll; + + /* SIGSYS. */ + struct + { + void *_call_addr; /* Calling user insn. */ + int _syscall; /* Triggering system call number. */ + unsigned int _arch; /* AUDIT_ARCH_* of syscall. */ + } _sigsys; } _sifields; } siginfo_t;
@@ -120,6 +128,9 @@ typedef struct siginfo # define si_addr _sifields._sigfault.si_addr # define si_band _sifields._sigpoll.si_band # define si_fd _sifields._sigpoll.si_fd +# define si_call_addr _sifields._sigsys._call_addr +# define si_syscall _sifields._sigsys._syscall +# define si_arch _sifields._sigsys._arch
# ifdef __USE_GNU # define si_imm _sifields._sigfault._si_imm diff --git a/libc/sysdeps/linux/mips/bits/siginfo.h b/libc/sysdeps/linux/mips/bits/siginfo.h index 5199d4d..b204301 100644 --- a/libc/sysdeps/linux/mips/bits/siginfo.h +++ b/libc/sysdeps/linux/mips/bits/siginfo.h @@ -108,6 +108,14 @@ typedef struct siginfo long int si_band; /* Band event for SIGPOLL. */ int si_fd; } _sigpoll; + + /* SIGSYS. */ + struct + { + void *_call_addr; /* Calling user insn. */ + int _syscall; /* Triggering system call number. */ + unsigned int _arch; /* AUDIT_ARCH_* of syscall. */ + } _sigsys; } _sifields; } siginfo_t;
@@ -127,6 +135,9 @@ typedef struct siginfo # define si_addr_lsb _sifields._sigfault.si_addr_lsb # define si_band _sifields._sigpoll.si_band # define si_fd _sifields._sigpoll.si_fd +# define si_call_addr _sifields._sigsys._call_addr +# define si_syscall _sifields._sigsys._syscall +# define si_arch _sifields._sigsys._arch
/* Values for `si_code'. Positive values are reserved for kernel-generated diff --git a/libc/sysdeps/linux/sparc/bits/siginfo.h b/libc/sysdeps/linux/sparc/bits/siginfo.h index 3ffeb6d..da1c838 100644 --- a/libc/sysdeps/linux/sparc/bits/siginfo.h +++ b/libc/sysdeps/linux/sparc/bits/siginfo.h @@ -104,6 +104,14 @@ typedef struct siginfo int si_band; /* Band event for SIGPOLL. */ int si_fd; } _sigpoll; + + /* SIGSYS. */ + struct + { + void *_call_addr; /* Calling user insn. */ + int _syscall; /* Triggering system call number. */ + unsigned int _arch; /* AUDIT_ARCH_* of syscall. */ + } _sigsys; } _sifields; } siginfo_t;
@@ -123,6 +131,9 @@ typedef struct siginfo # define si_trapno _sifields._sigfault.si_trapno # define si_band _sifields._sigpoll.si_band # define si_fd _sifields._sigpoll.si_fd +# define si_call_addr _sifields._sigsys._call_addr +# define si_syscall _sifields._sigsys._syscall +# define si_arch _sifields._sigsys._arch
/* Values for `si_code'. Positive values are reserved for kernel-generated diff --git a/libpthread/nptl/Makefile.in b/libpthread/nptl/Makefile.in index 0a981cd..55eeba2 100644 --- a/libpthread/nptl/Makefile.in +++ b/libpthread/nptl/Makefile.in @@ -92,7 +92,7 @@ $(top_builddir)lib/libpthread.a: $(libpthread-a-y) $(Q)$(RM) $@ $(do_ar)
-$(libpthread_OUT)/pthread-errnos.h: $(top_srcdir)extra/scripts/gen-as-const.awk | headers +$(libpthread_OUT)/pthread-errnos.h: $(top_srcdir)extra/scripts/gen-as-const.awk $(libpthread_OUT)/pthread-errnos.h: $(libpthread_DIR)/pthread-errnos.sym @$(disp_gen) $(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< \ diff --git a/libpthread/nptl/sysdeps/Makefile.commonarch b/libpthread/nptl/sysdeps/Makefile.commonarch index a5952a6..7f531f5 100644 --- a/libpthread/nptl/sysdeps/Makefile.commonarch +++ b/libpthread/nptl/sysdeps/Makefile.commonarch @@ -40,7 +40,7 @@ librt_arch_COBJ = $(patsubst %.c,$(libpthread_arch_OUT)/%.o,$(librt_arch_CSRC)) librt_arch_SOBJ = $(patsubst %.S,$(libpthread_arch_OUT)/%.o,$(librt_arch_SSRC)) librt_arch_OBJS = $(librt_arch_COBJ) $(librt_arch_SOBJ)
-$(libpthread_arch_OUT)/tcb-offsets.h: $(top_srcdir)extra/scripts/gen-as-const.awk | headers +$(libpthread_arch_OUT)/tcb-offsets.h: $(top_srcdir)extra/scripts/gen-as-const.awk $(libpthread_arch_OUT)/tcb-offsets.h: $(libpthread_arch_DIR)/tcb-offsets.sym @$(disp_gen) $(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< \ diff --git a/libpthread/nptl/sysdeps/pthread/Makefile.in b/libpthread/nptl/sysdeps/pthread/Makefile.in index 84adfe0..849c75f 100644 --- a/libpthread/nptl/sysdeps/pthread/Makefile.in +++ b/libpthread/nptl/sysdeps/pthread/Makefile.in @@ -78,7 +78,7 @@ $(libpthread_pthread_OUT)/pt-crti.o: $(libpthread_pthread_OUT)/pt-crti.S $(libpthread_pthread_OUT)/pt-crtn.o: $(libpthread_pthread_OUT)/pt-crtn.S $(compile.S)
-$(libpthread_pthread_OUT)/pt-initfini.s: $(PTHREAD_INITFINI) | $(top_builddir)include/bits/uClibc_config.h +$(libpthread_pthread_OUT)/pt-initfini.s: $(PTHREAD_INITFINI) | $(headers_dep) $(compile.c) $(libpthread_pthread_OUT)/defs.h: $(PTHREAD_INITFINI) $(do_sed) -n -e '/@TESTS_BEGIN/,/@TESTS_END/p' $< | \ diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile.commonarch b/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile.commonarch index e4a5fc5..4e14773 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile.commonarch +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile.commonarch @@ -137,7 +137,7 @@ endif PTHREAD_LINUX_SYM := $(notdir $(wildcard $(libpthread_linux_DIR)/*.sym)) PTHREAD_LINUX_SYM_H := $(addprefix $(libpthread_linux_OUT)/,$(PTHREAD_LINUX_SYM:.sym=.h))
-$(PTHREAD_LINUX_SYM_H): $(top_srcdir)extra/scripts/gen-as-const.awk | headers +$(PTHREAD_LINUX_SYM_H): $(top_srcdir)extra/scripts/gen-as-const.awk $(PTHREAD_LINUX_SYM_H): $(libpthread_linux_OUT)/%.h: $(libpthread_linux_DIR)/%.sym @$(disp_gen) $(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< \ diff --git a/libpthread/nptl_db/ChangeLog b/libpthread/nptl_db/ChangeLog index 52c8491..92021cb 100644 --- a/libpthread/nptl_db/ChangeLog +++ b/libpthread/nptl_db/ChangeLog @@ -1,3 +1,26 @@ +2007-05-16 Roland McGrath roland@redhat.com + + * td_thr_get_info.c: Fake the results for TH->th_unique == 0. + * td_thr_validate.c: Likewise. + * td_thr_setgregs.c: Likewise. + * td_thr_setfpregs.c: Likewise. + * td_thr_getgregs.c: Likewise. + * td_thr_getfpregs.c: Likewise. + * td_thr_tlsbase.c: Likewise. + + * structs.def: Add DB_VARIABLE (__nptl_initial_report_events). + * db_info.c: Add necessary declaration. + * td_thr_event_enable.c: Set __nptl_initial_report_events too. + + * td_ta_thr_iter.c (iterate_thread_list): Make FAKE_EMPTY bool. + Use th_unique=0 in fake descriptor before initialization. + + * td_ta_map_lwp2thr.c (__td_ta_lookup_th_unique): New function, broken + out of ... + (td_ta_map_lwp2thr): ... here, call it. But don't before __stack_user + is initialized, then fake a handle with th_unique=0. + * thread_dbP.h: Declare it. + 2004-09-09 Roland McGrath roland@redhat.com
* td_ta_map_lwp2thr.c (td_ta_map_lwp2thr): Don't abort if inferior's diff --git a/libpthread/nptl_db/Makefile.in b/libpthread/nptl_db/Makefile.in index 76102e6..5a493d8 100644 --- a/libpthread/nptl_db/Makefile.in +++ b/libpthread/nptl_db/Makefile.in @@ -22,13 +22,13 @@ libthread_db_FULL_NAME := libthread_db-$(VERSION).so libthread_db_DIR := $(top_srcdir)libpthread/nptl_db libthread_db_OUT := $(top_builddir)libpthread/nptl_db
-libthread_db_SRC := $(wildcard $(libthread_db_DIR)/td_*.c) \ - $(libthread_db_DIR)/fetch-value.c +libthread_db_SRC := $(notdir $(wildcard $(libthread_db_DIR)/td_*.c) \ + $(libthread_db_DIR)/fetch-value.c) ifeq ($(UCLIBC_SUSV4_LEGACY),) libthread_db_SRC := $(filter-out td_ta_setconcurrency.c,$(libthread_db_SRC)) endif
-libthread_db_OBJ := $(patsubst $(libthread_db_DIR)/%.c,$(libthread_db_OUT)/%.o,$(libthread_db_SRC)) +libthread_db_OBJ := $(addprefix $(libthread_db_OUT)/,$(libthread_db_SRC:.c=.o))
libthread_db-so-y := $(libthread_db_OBJ:.o=.oS) ifeq ($(DOPIC),y) @@ -37,7 +37,7 @@ else libthread_db-a-y := $(libthread_db_OBJ) endif
-libthread_db-multi-y := $(libthread_db_SRC) +libthread_db-multi-y := $(addprefix $(libthread_db_DIR)/,$(libthread_db_SRC))
lib-a-$(PTHREADS_DEBUG_SUPPORT) += $(top_builddir)lib/libthread_db.a lib-so-$(PTHREADS_DEBUG_SUPPORT) += $(top_builddir)lib/libthread_db.so diff --git a/libpthread/nptl_db/db_info.c b/libpthread/nptl_db/db_info.c index 521ad78..a57a053 100644 --- a/libpthread/nptl_db/db_info.c +++ b/libpthread/nptl_db/db_info.c @@ -1,7 +1,7 @@ /* This file is included by pthread_create.c to define in libpthread all the magic symbols required by libthread_db.
- Copyright (C) 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or @@ -37,6 +37,8 @@ typedef struct
typedef struct link_map link_map;
+/* Actually static in nptl/init.c, but we only need it for typeof. */ +extern bool __nptl_initial_report_events;
#define schedparam_sched_priority schedparam.sched_priority
diff --git a/libpthread/nptl_db/structs.def b/libpthread/nptl_db/structs.def index 915867b..bb571d4 100644 --- a/libpthread/nptl_db/structs.def +++ b/libpthread/nptl_db/structs.def @@ -1,5 +1,5 @@ /* List of types and symbols in libpthread examined by libthread_db. - Copyright (C) 2003, 2006 Free Software Foundation, Inc. + Copyright (C) 2003, 2006, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or @@ -55,6 +55,7 @@ DB_FUNCTION (__nptl_death_event) DB_SYMBOL (__nptl_threads_events) DB_VARIABLE (__nptl_nthreads) DB_VARIABLE (__nptl_last_event) +DB_VARIABLE (__nptl_initial_report_events)
DB_ARRAY_VARIABLE (__pthread_keys) DB_STRUCT (pthread_key_struct) diff --git a/libpthread/nptl_db/td_ta_map_lwp2thr.c b/libpthread/nptl_db/td_ta_map_lwp2thr.c index 9709777..6b4382f 100644 --- a/libpthread/nptl_db/td_ta_map_lwp2thr.c +++ b/libpthread/nptl_db/td_ta_map_lwp2thr.c @@ -1,5 +1,5 @@ /* Which thread is running on an LWP? - Copyright (C) 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or @@ -23,8 +23,8 @@
td_err_e -td_ta_map_lwp2thr (const td_thragent_t *ta_arg, - lwpid_t lwpid, td_thrhandle_t *th) +__td_ta_lookup_th_unique (const td_thragent_t *ta_arg, + lwpid_t lwpid, td_thrhandle_t *th) { td_thragent_t *const ta = (td_thragent_t *) ta_arg; ps_err_e err; @@ -117,9 +117,6 @@ td_ta_map_lwp2thr (const td_thragent_t *ta_arg,
switch (ta->ta_howto) { - case ta_howto_unknown: - return TD_DBERR; - default: return TD_DBERR;
@@ -131,6 +128,7 @@ td_ta_map_lwp2thr (const td_thragent_t *ta_arg, 0, regs, &addr); if (terr != TD_OK) return terr; + /* In this descriptor the nelem word is overloaded as the bias. */ addr += (int32_t) DB_DESC_NELEM (ta->ta_howto_data.reg); th->th_unique = addr; @@ -142,22 +140,22 @@ td_ta_map_lwp2thr (const td_thragent_t *ta_arg, if (&ps_get_thread_area == NULL) return TD_NOCAPAB;
- /* A la x86-64, there is a constant magic index for get_thread_area. */ - if (ps_get_thread_area (ta->ph, lwpid, - ta->ta_howto_data.const_thread_area, - &th->th_unique) != PS_OK) - return TD_ERR; /* XXX Other error value? */ - break; + /* A la x86-64, there is a magic index for get_thread_area. */ + if (ps_get_thread_area (ta->ph, lwpid, + ta->ta_howto_data.const_thread_area, + &th->th_unique) != PS_OK) + return TD_ERR; /* XXX Other error value? */ + break;
- case ta_howto_reg_thread_area: + case ta_howto_reg_thread_area: if (&ps_get_thread_area == NULL) return TD_NOCAPAB;
- /* A la i386, there is a register with an index for get_thread_area. */ - if (ps_lgetregs (ta->ph, lwpid, regs) != PS_OK) - return TD_ERR; - terr = _td_fetch_value_local (ta, ta->ta_howto_data.reg_thread_area, -1, - 0, regs, &addr); + /* A la i386, a register holds the index for get_thread_area. */ + if (ps_lgetregs (ta->ph, lwpid, regs) != PS_OK) + return TD_ERR; + terr = _td_fetch_value_local (ta, ta->ta_howto_data.reg_thread_area, + -1, 0, regs, &addr); if (terr != TD_OK) return terr; /* In this descriptor the nelem word is overloaded as scale factor. */ @@ -171,7 +169,40 @@ td_ta_map_lwp2thr (const td_thragent_t *ta_arg, }
/* Found it. Now complete the `td_thrhandle_t' object. */ - th->th_ta_p = (td_thragent_t *) ta; + th->th_ta_p = ta;
return TD_OK; } + +td_err_e +td_ta_map_lwp2thr (const td_thragent_t *ta_arg, + lwpid_t lwpid, td_thrhandle_t *th) +{ + td_thragent_t *const ta = (td_thragent_t *) ta_arg; + + /* We cannot rely on thread registers and such information at all + before __pthread_initialize_minimal has gotten far enough. They + sometimes contain garbage that would confuse us, left by the kernel + at exec. So if it looks like initialization is incomplete, we only + fake a special descriptor for the initial thread. */ + + psaddr_t list; + td_err_e err = DB_GET_SYMBOL (list, ta, __stack_user); + if (err != TD_OK) + return err; + + err = DB_GET_FIELD (list, ta, list, list_t, next, 0); + if (err != TD_OK) + return err; + + if (list == 0) + { + if (ps_getpid (ta->ph) != lwpid) + return TD_ERR; + th->th_ta_p = ta; + th->th_unique = 0; + return TD_OK; + } + + return __td_ta_lookup_th_unique (ta_arg, lwpid, th); +} diff --git a/libpthread/nptl_db/td_ta_thr_iter.c b/libpthread/nptl_db/td_ta_thr_iter.c index 1fd02ef..0f1b2bf 100644 --- a/libpthread/nptl_db/td_ta_thr_iter.c +++ b/libpthread/nptl_db/td_ta_thr_iter.c @@ -1,5 +1,6 @@ /* Iterate over a process's threads. - Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. + Copyright (C) 1999,2000,2001,2002,2003,2004,2007 + Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper drepper@redhat.com, 1999.
@@ -23,7 +24,7 @@ static td_err_e iterate_thread_list (td_thragent_t *ta, td_thr_iter_f *callback, void *cbdata_p, td_thr_state_e state, int ti_pri, - psaddr_t head, int fake_empty) + psaddr_t head, bool fake_empty) { td_err_e err; psaddr_t next, ofs; @@ -40,13 +41,13 @@ iterate_thread_list (td_thragent_t *ta, td_thr_iter_f *callback,
if (next == 0 && fake_empty) { - /* __pthread_initialize_minimal has not run. - There is just the main thread to return. */ - td_thrhandle_t th; - err = td_ta_map_lwp2thr (ta, ps_getpid (ta->ph), &th); - if (err == TD_OK) - err = callback (&th, cbdata_p) != 0 ? TD_DBERR : TD_OK; - return err; + /* __pthread_initialize_minimal has not run. There is just the main + thread to return. We cannot rely on its thread register. They + sometimes contain garbage that would confuse us, left by the + kernel at exec. So if it looks like initialization is incomplete, + we only fake a special descriptor for the initial thread. */ + td_thrhandle_t th = { ta, 0 }; + return callback (&th, cbdata_p) != 0 ? TD_DBERR : TD_OK; }
/* Cache the offset from struct pthread to its list_t member. */ @@ -135,13 +136,15 @@ td_ta_thr_iter (const td_thragent_t *ta_arg, td_thr_iter_f *callback,
err = DB_GET_SYMBOL (list, ta, __stack_user); if (err == TD_OK) - err = iterate_thread_list (ta, callback, cbdata_p, state, ti_pri, list, 1); + err = iterate_thread_list (ta, callback, cbdata_p, state, ti_pri, + list, true);
/* And the threads with stacks allocated by the implementation. */ if (err == TD_OK) err = DB_GET_SYMBOL (list, ta, stack_used); if (err == TD_OK) - err = iterate_thread_list (ta, callback, cbdata_p, state, ti_pri, list, 0); + err = iterate_thread_list (ta, callback, cbdata_p, state, ti_pri, + list, false);
return err; } diff --git a/libpthread/nptl_db/td_thr_event_enable.c b/libpthread/nptl_db/td_thr_event_enable.c index f49682d..fd94580 100644 --- a/libpthread/nptl_db/td_thr_event_enable.c +++ b/libpthread/nptl_db/td_thr_event_enable.c @@ -1,5 +1,5 @@ /* Enable event process-wide. - Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 1999, 2001, 2002, 2003, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper drepper@redhat.com, 1999.
@@ -25,7 +25,25 @@ td_thr_event_enable (const td_thrhandle_t *th, int onoff) { LOG ("td_thr_event_enable");
- /* Write the new value into the thread data structure. */ - return DB_PUT_FIELD (th->th_ta_p, th->th_unique, pthread, report_events, 0, + if (th->th_unique != 0) + { + /* Write the new value into the thread data structure. */ + td_err_e err = DB_PUT_FIELD (th->th_ta_p, th->th_unique, pthread, + report_events, 0, + (psaddr_t) 0 + (onoff != 0)); + if (err != TD_OK) + return err; + + /* Just in case we are in the window between initializing __stack_user + and copying from __nptl_initial_report_events, we set it too. + It doesn't hurt to do this for non-initial threads, since it + won't be consulted again anyway. It would take another fetch + to get the tid and determine this isn't the initial thread, + so just do it always. */ + } + + /* We are faking it for the initial thread before its thread + descriptor is set up. */ + return DB_PUT_VALUE (th->th_ta_p, __nptl_initial_report_events, 0, (psaddr_t) 0 + (onoff != 0)); } diff --git a/libpthread/nptl_db/td_thr_get_info.c b/libpthread/nptl_db/td_thr_get_info.c index 09d0d1a..27d5d70 100644 --- a/libpthread/nptl_db/td_thr_get_info.c +++ b/libpthread/nptl_db/td_thr_get_info.c @@ -1,5 +1,5 @@ /* Get thread information. - Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 1999,2000,2001,2002,2003,2007 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper drepper@redhat.com, 1999.
@@ -31,35 +31,49 @@ td_thr_get_info (const td_thrhandle_t *th, td_thrinfo_t *infop)
LOG ("td_thr_get_info");
- /* Copy the whole descriptor in once so we can access the several - fields locally. Excess copying in one go is much better than - multiple ps_pdread calls. */ - err = DB_GET_STRUCT (copy, th->th_ta_p, th->th_unique, pthread); - if (err != TD_OK) - return err; - - err = DB_GET_FIELD_ADDRESS (tls, th->th_ta_p, th->th_unique, - pthread, specific, 0); - if (err != TD_OK) - return err; - - err = DB_GET_FIELD_LOCAL (schedpolicy, th->th_ta_p, copy, pthread, - schedpolicy, 0); - if (err != TD_OK) - return err; - err = DB_GET_FIELD_LOCAL (schedprio, th->th_ta_p, copy, pthread, - schedparam_sched_priority, 0); - if (err != TD_OK) - return err; - err = DB_GET_FIELD_LOCAL (tid, th->th_ta_p, copy, pthread, tid, 0); - if (err != TD_OK) - return err; - err = DB_GET_FIELD_LOCAL (cancelhandling, th->th_ta_p, copy, pthread, - cancelhandling, 0); - if (err != TD_OK) - return err; - err = DB_GET_FIELD_LOCAL (report_events, th->th_ta_p, copy, pthread, - report_events, 0); + if (th->th_unique == 0) + { + /* Special case for the main thread before initialization. */ + copy = NULL; + tls = 0; + cancelhandling = 0; + schedprio = 0; + tid = 0; + err = DB_GET_VALUE (report_events, th->th_ta_p, + __nptl_initial_report_events, 0); + } + else + { + /* Copy the whole descriptor in once so we can access the several + fields locally. Excess copying in one go is much better than + multiple ps_pdread calls. */ + err = DB_GET_STRUCT (copy, th->th_ta_p, th->th_unique, pthread); + if (err != TD_OK) + return err; + + err = DB_GET_FIELD_ADDRESS (tls, th->th_ta_p, th->th_unique, + pthread, specific, 0); + if (err != TD_OK) + return err; + + err = DB_GET_FIELD_LOCAL (schedpolicy, th->th_ta_p, copy, pthread, + schedpolicy, 0); + if (err != TD_OK) + return err; + err = DB_GET_FIELD_LOCAL (schedprio, th->th_ta_p, copy, pthread, + schedparam_sched_priority, 0); + if (err != TD_OK) + return err; + err = DB_GET_FIELD_LOCAL (tid, th->th_ta_p, copy, pthread, tid, 0); + if (err != TD_OK) + return err; + err = DB_GET_FIELD_LOCAL (cancelhandling, th->th_ta_p, copy, pthread, + cancelhandling, 0); + if (err != TD_OK) + return err; + err = DB_GET_FIELD_LOCAL (report_events, th->th_ta_p, copy, pthread, + report_events, 0); + } if (err != TD_OK) return err;
@@ -86,9 +100,10 @@ td_thr_get_info (const td_thrhandle_t *th, td_thrinfo_t *infop) infop->ti_lid = tid == 0 ? ps_getpid (th->th_ta_p->ph) : (uintptr_t) tid; infop->ti_traceme = report_events != 0;
- err = DB_GET_FIELD_LOCAL (infop->ti_startfunc, th->th_ta_p, copy, pthread, - start_routine, 0); - if (err == TD_OK) + if (copy != NULL) + err = DB_GET_FIELD_LOCAL (infop->ti_startfunc, th->th_ta_p, copy, pthread, + start_routine, 0); + if (copy != NULL && err == TD_OK) { uint32_t idx; for (idx = 0; idx < TD_EVENTSIZE; ++idx) diff --git a/libpthread/nptl_db/td_thr_getfpregs.c b/libpthread/nptl_db/td_thr_getfpregs.c index ff4b599..4f4742a 100644 --- a/libpthread/nptl_db/td_thr_getfpregs.c +++ b/libpthread/nptl_db/td_thr_getfpregs.c @@ -1,5 +1,5 @@ /* Get a thread's floating-point register set. - Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 1999, 2001, 2002, 2003, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper drepper@redhat.com, 1999.
@@ -28,6 +28,11 @@ td_thr_getfpregs (const td_thrhandle_t *th, prfpregset_t *regset)
LOG ("td_thr_getfpregs");
+ if (th->th_unique == 0) + /* Special case for the main thread before initialization. */ + return ps_lgetfpregs (th->th_ta_p->ph, ps_getpid (th->th_ta_p->ph), + regset) != PS_OK ? TD_ERR : TD_OK; + /* We have to get the state and the PID for this thread. */ err = DB_GET_FIELD (cancelhandling, th->th_ta_p, th->th_unique, pthread, cancelhandling, 0); diff --git a/libpthread/nptl_db/td_thr_getgregs.c b/libpthread/nptl_db/td_thr_getgregs.c index 497941b..d5f0f61 100644 --- a/libpthread/nptl_db/td_thr_getgregs.c +++ b/libpthread/nptl_db/td_thr_getgregs.c @@ -1,5 +1,5 @@ /* Get a thread's general register set. - Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2001, 2002, 2003, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper drepper@redhat.com, 1999.
@@ -28,6 +28,11 @@ td_thr_getgregs (const td_thrhandle_t *th, prgregset_t regset)
LOG ("td_thr_getgregs");
+ if (th->th_unique == 0) + /* Special case for the main thread before initialization. */ + return ps_lgetregs (th->th_ta_p->ph, ps_getpid (th->th_ta_p->ph), + regset) != PS_OK ? TD_ERR : TD_OK; + /* We have to get the state and the PID for this thread. */ err = DB_GET_FIELD (cancelhandling, th->th_ta_p, th->th_unique, pthread, cancelhandling, 0); diff --git a/libpthread/nptl_db/td_thr_setfpregs.c b/libpthread/nptl_db/td_thr_setfpregs.c index 3c4e8ed..3154953 100644 --- a/libpthread/nptl_db/td_thr_setfpregs.c +++ b/libpthread/nptl_db/td_thr_setfpregs.c @@ -1,5 +1,5 @@ /* Set a thread's floating-point register set. - Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 1999, 2001, 2002, 2003, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper drepper@redhat.com, 1999.
@@ -28,6 +28,11 @@ td_thr_setfpregs (const td_thrhandle_t *th, const prfpregset_t *fpregs)
LOG ("td_thr_setfpregs");
+ if (th->th_unique == 0) + /* Special case for the main thread before initialization. */ + return ps_lsetfpregs (th->th_ta_p->ph, ps_getpid (th->th_ta_p->ph), + fpregs) != PS_OK ? TD_ERR : TD_OK; + /* We have to get the state and the PID for this thread. */ err = DB_GET_FIELD (cancelhandling, th->th_ta_p, th->th_unique, pthread, cancelhandling, 0); diff --git a/libpthread/nptl_db/td_thr_setgregs.c b/libpthread/nptl_db/td_thr_setgregs.c index 83d2cd9..5945dea 100644 --- a/libpthread/nptl_db/td_thr_setgregs.c +++ b/libpthread/nptl_db/td_thr_setgregs.c @@ -1,5 +1,5 @@ /* Set a thread's general register set. - Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 1999, 2001, 2002, 2003, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper drepper@redhat.com, 1999.
@@ -28,6 +28,11 @@ td_thr_setgregs (const td_thrhandle_t *th, prgregset_t gregs)
LOG ("td_thr_setgregs");
+ if (th->th_unique == 0) + /* Special case for the main thread before initialization. */ + return ps_lsetregs (th->th_ta_p->ph, ps_getpid (th->th_ta_p->ph), + gregs) != PS_OK ? TD_ERR : TD_OK; + /* We have to get the state and the PID for this thread. */ err = DB_GET_FIELD (cancelhandling, th->th_ta_p, th->th_unique, pthread, cancelhandling, 0); diff --git a/libpthread/nptl_db/td_thr_tlsbase.c b/libpthread/nptl_db/td_thr_tlsbase.c index f7d4c29..9f98bd9 100644 --- a/libpthread/nptl_db/td_thr_tlsbase.c +++ b/libpthread/nptl_db/td_thr_tlsbase.c @@ -1,5 +1,5 @@ /* Locate TLS data for a thread. - Copyright (C) 2003, 2006 Free Software Foundation, Inc. + Copyright (C) 2003, 2006, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or @@ -29,8 +29,29 @@ td_thr_tlsbase (const td_thrhandle_t *th, if (modid < 1) return TD_NOTLS;
+ psaddr_t pd = th->th_unique; + if (pd == 0) + { + /* This is the fake handle for the main thread before libpthread + initialization. We are using 0 for its th_unique because we can't + trust that its thread register has been initialized. But we need + a real pointer to have any TLS access work. In case of dlopen'd + libpthread, initialization might not be for quite some time. So + try looking up the thread register now. Worst case, it's nonzero + uninitialized garbage and we get bogus results for TLS access + attempted too early. Tough. */ + + td_thrhandle_t main_th; + err = __td_ta_lookup_th_unique (th->th_ta_p, ps_getpid (th->th_ta_p->ph), + &main_th); + if (err == 0) + pd = main_th.th_unique; + if (pd == 0) + return TD_TLSDEFER; + } + /* Get the DTV pointer from the thread descriptor. */ - err = DB_GET_FIELD (dtv, th->th_ta_p, th->th_unique, pthread, dtvp, 0); + err = DB_GET_FIELD (dtv, th->th_ta_p, pd, pthread, dtvp, 0); if (err != TD_OK) return err;
diff --git a/libpthread/nptl_db/td_thr_validate.c b/libpthread/nptl_db/td_thr_validate.c index 49c30c1..1b96b51 100644 --- a/libpthread/nptl_db/td_thr_validate.c +++ b/libpthread/nptl_db/td_thr_validate.c @@ -1,5 +1,5 @@ /* Validate a thread handle. - Copyright (C) 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 1999,2001,2002,2003,2004,2007 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper drepper@redhat.com, 1999.
@@ -74,16 +74,10 @@ td_thr_validate (const td_thrhandle_t *th) if (err == TD_OK) err = check_thread_list (th, list, &uninit);
- if (err == TD_NOTHR && uninit) - { - /* __pthread_initialize_minimal has not run yet. - But the main thread still has a valid ID. */ - td_thrhandle_t main_th; - err = td_ta_map_lwp2thr (th->th_ta_p, - ps_getpid (th->th_ta_p->ph), &main_th); - if (err == TD_OK && th->th_unique != main_th.th_unique) - err = TD_NOTHR; - } + if (err == TD_NOTHR && uninit && th->th_unique == 0) + /* __pthread_initialize_minimal has not run yet. + There is only the special case thread handle. */ + err = TD_OK; }
return err; diff --git a/libpthread/nptl_db/thread_dbP.h b/libpthread/nptl_db/thread_dbP.h index 24623ef..b8399f7 100644 --- a/libpthread/nptl_db/thread_dbP.h +++ b/libpthread/nptl_db/thread_dbP.h @@ -1,5 +1,5 @@ /* Private header for thread debug library - Copyright (C) 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or @@ -254,4 +254,7 @@ extern td_err_e _td_store_value_local (td_thragent_t *ta, extern td_err_e _td_check_sizeof (td_thragent_t *ta, uint32_t *sizep, int sizep_name) attribute_hidden;
+extern td_err_e __td_ta_lookup_th_unique (const td_thragent_t *ta, + lwpid_t lwpid, td_thrhandle_t *th); + #endif /* thread_dbP.h */ diff --git a/librt/Makefile.in b/librt/Makefile.in index fbbf5b4..1536a5c 100644 --- a/librt/Makefile.in +++ b/librt/Makefile.in @@ -13,19 +13,15 @@ LDFLAGS-$(UCLIBC_FORMAT_DSBT_ELF)-librt.so := -Wl,--dsbt-index=9 LDFLAGS-librt.so := $(LDFLAGS) LIBS-librt.so := $(LIBS) ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y) -LIBS-librt.so += $(top_builddir)lib/libdl.so $(top_builddir)lib/libpthread.so +LIBS-librt.so += $(top_builddir)lib/libpthread.so \ + $(CC_FLAG_ASNEEDED) $(top_builddir)lib/libdl.so $(CC_FLAG_NO_ASNEEDED) endif -START_FILE-librt.so := $(SHARED_START_FILES) -END_FILE-librt.so := $(SHARED_END_FILES) -
librt_FULL_NAME := librt-$(VERSION).so
librt_DIR := $(top_srcdir)librt librt_OUT := $(top_builddir)librt
-ifeq ($(UCLIBC_HAS_REALTIME),y) - librt_SRC := $(notdir $(wildcard $(librt_DIR)/*.c)) librt_filter_SRC := ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y) @@ -45,8 +41,10 @@ librt_filter_SRC += $(if $(UCLIBC_HAS_ADVANCED_REALTIME),, \ spawn_faction_addopen.c \ spawn_faction_init.c)
-librt_SRC := $(filter-out $(librt_filter_SRC),$(librt_SRC)) +librt_filter_SRC += $(if $(UCLIBC_HAS_STUBS),,rt_stubs.c) +librt_filter_SRC += $(if $(HAS_NO_THREADS),dso_handle.c)
+librt_SRC := $(filter-out $(librt_filter_SRC),$(librt_SRC)) librt_OBJ := $(patsubst %.c,$(librt_OUT)/%.o,$(librt_SRC)) librt_OBJ += $(patsubst $(librt_DIR)/%.S,$(librt_OUT)/%.o,$(librt_SSRC))
@@ -60,15 +58,19 @@ librt-a-y += $(librt_OBJ) endif librt-so-y += $(librt_OBJ:.o=.oS)
+ifeq ($(UCLIBC_HAS_REALTIME),y) lib-a-y += $(top_builddir)lib/librt.a lib-so-y += $(top_builddir)lib/librt.so endif
+librt-dep-y := $(libc.depend) +librt-dep-$(UCLIBC_HAS_THREADS_NATIVE) += $(libpthread.depend) $(libdl.depend)
-ifeq ($(DOPIC)$(UCLIBC_HAS_THREADS_NATIVE),yn) -$(top_builddir)lib/librt.so: $(top_builddir)lib/librt.a $(libc.depend) +# for NPTL we need SHARED regardless of DOPIC +ifeq ($(if $(UCLIBC_HAS_THREADS_NATIVE),,$(DOPIC)),y) +$(top_builddir)lib/librt.so: $(top_builddir)lib/librt.a $(librt-dep-y) else -$(top_builddir)lib/librt.so: $(librt_OUT)/librt_so.a $(libc.depend) $(libpthread.depend) $(libdl.depend) +$(top_builddir)lib/librt.so: $(librt_OUT)/librt_so.a $(librt-dep-y) endif $(call link.so,$(librt_FULL_NAME),$(ABI_VERSION))
@@ -76,7 +78,7 @@ $(librt_OUT)/librt_so.a: $(librt-so-y) $(Q)$(RM) $@ $(do_ar)
-$(top_builddir)lib/librt.a: $(librt-a-y) | $(top_builddir)lib +$(top_builddir)lib/librt.a: $(librt-a-y) $(Q)$(RM) $@ $(do_ar)
diff --git a/librt/dso_handle.c b/librt/dso_handle.c new file mode 100644 index 0000000..6339071 --- /dev/null +++ b/librt/dso_handle.c @@ -0,0 +1,5 @@ +/* Copyright (C) 2015 Bernhard Reutner-Fischer + * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball. + */ + +const void *const __dso_handle attribute_hidden = &__dso_handle; diff --git a/test/silly/Makefile.in b/test/silly/Makefile.in index 2114d4d..33f99d3 100644 --- a/test/silly/Makefile.in +++ b/test/silly/Makefile.in @@ -4,5 +4,9 @@ RET_hello := 42 RET_tiny := 42
-# missing internal headers, disable these -TESTS_DISABLED := tst-atomic tst-atomic-long +atomic_headers := -I$(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH) \ + -I$(top_srcdir)libc/sysdeps/linux \ + -I$(top_builddir)include + +CFLAGS_tst-atomic = $(atomic_headers) -fPIC +CFLAGS_tst-atomic-long = $(atomic_headers) -fPIC diff --git a/test/stdio/scanf_m.c b/test/stdio/scanf_m.c new file mode 100644 index 0000000..0ce78b6 --- /dev/null +++ b/test/stdio/scanf_m.c @@ -0,0 +1,24 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +int main(void) +{ + const char *buf = "hello world"; + char *ps = NULL, *pc = NULL; + char s[6], c; + + /* Check that %[...]/%c work. */ + sscanf(buf, "%[a-z] %c", s, &c); + /* Check that %m[...]/%mc work. */ + sscanf(buf, "%m[a-z] %mc", &ps, &pc); + + if (strcmp(ps, "hello") != 0 || *pc != 'w' || + strcmp(s, "hello") != 0 || c != 'w') + return 1; + + free(ps); + free(pc); + + return 0; +} diff --git a/utils/getconf.c b/utils/getconf.c index 408a574..3dd3d75 100644 --- a/utils/getconf.c +++ b/utils/getconf.c @@ -23,6 +23,7 @@ #include <stdio.h>
#define PACKAGE "getconf regression test" +#undef VERSION #define VERSION "" #define _(x) x #define error(status, errnum, fmt, ...) \
hooks/post-receive