Commit Graph

3244 Commits

Author SHA1 Message Date
Szabolcs Nagy 51d5f139ca add mlock2 syscall number from linux v4.4
this is mlock with a flags argument, new in linux commit
a8ca5d0ecbdde5cc3d7accacbd69968b0c98764e

as usual microblaze and sh don't have allocated syscall number yet.
2016-01-26 18:30:50 -05:00
Szabolcs Nagy aaa604052d add new PTRACE_O_SUSPEND_SECCOMP ptrace option
allows a ptracer process to disable/enable seccomp filters of the
traced process, useful for checkpoint/restore, new in v4.3 commit
13c4a90119d28cfcb6b5bdd820c233b86c2b0237
2016-01-26 18:30:30 -05:00
Szabolcs Nagy 8afd2a1d03 add new PR_CAP_AMBIENT and related defines to sys/prctl.h
ambient capability mask is new in linux v4.3, commit
58319057b7847667f0c9585b9de0e8932b0fdb08
2016-01-26 18:30:14 -05:00
Szabolcs Nagy 3934f49c01 update netpacket/packet.h to linux v4.3 2016-01-26 18:29:32 -05:00
Szabolcs Nagy 09001a8f97 add new membarrier, userfaultfd and switch_endian syscalls
new in linux v4.3 added for aarch64, arm, i386, mips, or1k, powerpc,
x32 and x86_64.

membarrier is a system wide memory barrier, moves most of the
synchronization cost to one side, new in kernel commit
5b25b13ab08f616efd566347d809b4ece54570d1

userfaultfd is useful for qemu and is new in kernel commit
8d2afd96c20316d112e04d935d9e09150e988397

switch_endian is powerpc only for switching endianness, new in commit
529d235a0e190ded1d21ccc80a73e625ebcad09b
2016-01-26 18:28:20 -05:00
Szabolcs Nagy 37bfb68f68 add new i386 socket syscall numbers
new in linux v4.3 commit 9dea5dc921b5f4045a18c63eb92e84dc274d17eb
direct calls instead of socketcall allow better seccomp filtering.

musl continues to use socketcalls internally on i386. (older kernels
would need a fallback mechanism if the direct calls were used.)
2016-01-26 18:28:04 -05:00
Szabolcs Nagy a5e133bf29 change the internal socketcall selection logic
only use SYS_socketcall if SYSCALL_USE_SOCKETCALL is defined
internally, otherwise use direct syscalls.

this commit does not change the current behaviour, it is
preparation for adding direct syscall numbers for i386.
2016-01-26 18:27:44 -05:00
Rich Felker f9b8df464d add ssp suppression to some arch-override files that may need it
these were not covered by the parent-level rules with the new build
system. in the old build system, the equivalent files were often in
arch/$(ARCH)/src and likewise lacked the suppression. this could lead
to early crashing (before thread pointer init) when libc itself was
built with stack protector enabled.
2016-01-25 20:06:31 -05:00
Rich Felker 1619127c11 use same object files for libc.a and libc.so if compiler produces PIC
now that .lo and .o files differ only by whether -fPIC is passed (and
no longer at the source level based on the SHARED macro), it's
possible to use the same object files for both static and shared libc
when the compiler would produce PIC for the static files anyway. this
happens if the user has included -fPIC in their CFLAGS or if the
compiler has been configured to produce PIE by default.

we use the .lo files for both, and still append -fPIC to the CFLAGS,
rather than using the .o files so that libc.so does not break
catastrophically if the user later removes -fPIC from CFLAGS in
config.mak or on the make command line. this also ensures that we get
full -fPIC in case -fpic, -fPIE, or some other lesser-PIC option was
passed in CFLAGS.
2016-01-25 19:57:38 -05:00
Rich Felker 5552ce5200 move dynamic linker to its own top-level directory, ldso
this eliminates the last need for the SHARED macro to control how
files in the src tree are compiled. the same code is used for both
libc.a and libc.so, with additional code for the dynamic linker (from
the new ldso tree) being added to libc.so but not libc.a. separate .o
and .lo object files still exist for the src tree, but the only
difference is that the .lo files are built as PIC.

in the future, if/when we add dlopen support for static-linked
programs, much of the code in dynlink.c may be moved back into the src
tree, but properly factored into separate source files. in that case,
the code in the ldso tree will be reduced to just the dynamic linker
entry point, self-relocation, and loading of libraries needed by the
main application.
2016-01-25 19:29:55 -05:00
Rich Felker 16f70388d4 adapt static dl_iterate_phdr not to depend on !defined(SHARED)
like elsewhere, use a weak alias that the dynamic linker will override
with a more complete version capable of handling shared libraries.
2016-01-25 19:12:41 -05:00
Rich Felker 4058795d49 move static-linked stub dlsym out of dynlink.c
the function name is still __-prefixed because it requires an asm
wrapper to pass the caller's address in order for RTLD_NEXT to work.

since this was the last function in dynlink.c still used for static
linking, now the whole file is conditional on SHARED being defined.
2016-01-25 19:04:45 -05:00
Rich Felker 14469371cd move static-linked stub dlopen out of dynlink.c 2016-01-25 18:58:06 -05:00
Rich Felker b98414732d move dlinfo out of dynlink.c 2016-01-25 18:55:35 -05:00
Rich Felker da1fe7f500 move dlclose out of dynlink.c to its own source file 2016-01-25 18:53:40 -05:00
Rich Felker 891e6547b4 move static-linked stub invalid dso handle checking out of dynlink.c 2016-01-25 18:51:33 -05:00
Rich Felker 4f8f038060 move static/stub version of dladdr out of dynlink.c 2016-01-25 18:44:29 -05:00
Rich Felker a4fbc82c8e factor dlerror and error-setting code out of dynlink.c
the ultimate goal of this change is to get all code used in libc.a out
of dynlink.c, so that the dynamic linker code can be moved to its own
tree and object files in the src tree can all be shared between libc.a
and libc.so.
2016-01-25 18:44:09 -05:00
Rich Felker e7a1118984 fix arm a_crash for big endian
contrary to commit 89e149d275, big
endian arm does need the instruction bytes in big endian order. rather
than trying to use a special encoding that works as arm or thumb,
simply encode the simplest/canonical undefined instructions dependent
on whether __thumb__ is defined.
2016-01-25 21:59:55 +00:00
Rich Felker 89e149d275 add native a_crash primitive for arm
the .byte directive encodes a guaranteed-undefined instruction, the
same one Linux fills the kuser helper page with when it's disabled.
the udf mnemonic and and .insn directives are not supported by old
binutils versions, and larger-than-byte integer directives would
produce the wrong output on big-endian.
2016-01-25 02:44:56 +00:00
Szabolcs Nagy 2c9acc51cd add new IP_BIND_ADDRESS_NO_PORT and IPPROTO_MPLS to netinet/in.h
IP_BIND_ADDRESS_NO_PORT is a SOL_IP socket option to delay src port
allocation until connect in case src ip is set with bind(port=0).
new in linux v4.2, commit 90c337da1524863838658078ec34241f45d8394d

IPPROTO_MPLS protocol number for mpls over ip.
new in linux v4.2, commit 730fc4371333636a00fed32c587fc1e85c5367e2
2016-01-24 19:19:29 -05:00
Szabolcs Nagy 4da2d96591 update netinet/tcp.h for linux v4.2
TCP_CC_INFO is a new socket option to get congestion control info without
netlink (union tcp_cc_info is in linux/inet_diag.h kernel header).
linux commit 6e9250f59ef9efb932c84850cd221f22c2a03c4a

TCP_SAVE_SYN, TCP_SAVED_SYN socket options are for saving and getting the
SYN headers of passive connections in a server application.
linux commit cd8ae85299d54155702a56811b2e035e63064d3d

Add new tcpi_* fields to struct tcp_info implementing RFC4898 counters.
linux commit 2efd055c53c06b7e89c167c98069bab9afce7e59
2016-01-24 19:18:51 -05:00
Szabolcs Nagy ecf02f4e8a add MS_LAZYTIME mount option to sys/mount.h
new in linux 4.0 commit 0ae45f63d4ef8d8eeec49c7d8b44a1775fff13e8,
used to update atime/mtime/ctime only in memory when possible.
2016-01-24 19:18:41 -05:00
Szabolcs Nagy 9f52c17eb2 add AF_MPLS (PF_MPLS) address family to socket.h
new in linux 4.0 commit 0189197f441602acdca3f97750d392a895b778fd.
2016-01-24 19:18:21 -05:00
Szabolcs Nagy ea4fc27d28 add MSG_FASTOPEN sendmsg/sendto flag to socket.h
This was new in linux 3.5 in commit cf60af03ca4e71134206809ea892e49b92a88896,
needed for tcp fastopen feature (sending data in TCP SYN packet).
2016-01-24 19:18:02 -05:00
Szabolcs Nagy bc443c3fe3 clean powerpc syscall.h
remove ifdefs for powerpc64.
2016-01-24 19:08:57 -05:00
Szabolcs Nagy f9c3a2e048 add missing powerpc specific PROT_SAO memory protection flag
this flag for strong access ordering was added in linux v2.6.27
commit aba46c5027cb59d98052231b36efcbbde9c77a1d
2016-01-24 19:08:40 -05:00
Szabolcs Nagy 2f6f3dccb4 fix powerpc MCL_* mlockall flags in bits/mman.h
the definitions didn't match the linux uapi headers.
2016-01-24 19:08:19 -05:00
Szabolcs Nagy 2d14fa39b0 fix aarch64 atomics to load/store 32bit only
a_ll/a_sc inline asm used 64bit register operands (%0) instead of 32bit
ones (%w0), this at least broke a_and_64 (which always cleared the top
32bit, leaking memory in malloc).
2016-01-24 19:07:35 -05:00
Rich Felker b17fbd3520 improve aarch64 atomics
aarch64 provides ll/sc variants with acquire/release memory order,
freeing us from the need to have full barriers both before and after
the ll/sc operation. previously they were not used because the a_cas
can fail without performing a_sc, in which case half of the barrier
would be omitted. instead, define a custom version of a_cas for
aarch64 which uses a_barrier explicitly when aborting the cas
operation. aside from cas, other operations built on top of ll/sc are
not affected since they never abort but rather loop until they
succeed.

a split ll/sc version of the pointer-sized a_cas_p is also introduced
using the same technique.

patch by Szabolcs Nagy.
2016-01-23 14:03:40 -05:00
Rich Felker 0f5eb3de29 add arch/abi info to dynamic linker's id/version output 2016-01-22 04:04:16 +00:00
Rich Felker 5a2e88257a remove arch/$(ARCH)/src from the build system
the files that used to come from extra src dirs under the arch dir
have all been removed or moved to appropriate places under the main
src tree.
2016-01-22 03:58:51 +00:00
Rich Felker 4de1bc1164 remove sh port's __fpscr_values source file
commit f3ddd17380, the dynamic linker
bootstrap overhaul, silently disabled the definition of __fpscr_values
in this file since libc.so's copy of __fpscr_values now comes from
crt_arch.h, the same place the public definition in the main program's
crt1.o ultimately comes from. remove this file which is no longer in
use.
2016-01-22 03:50:58 +00:00
Rich Felker 007907a93c move sh port's __shcall internal function from arch/sh/src to src tree 2016-01-22 03:50:08 +00:00
Rich Felker 230bfe1a7d move sh __unmapself code from arch/sh/src to main src tree 2016-01-22 03:46:00 +00:00
Rich Felker 66215afc2e move x32 sysinfo impl and syscall fixup code out of arch/x32/src
all such arch-specific translation units are being moved to
appropriate arch dirs under the main src tree.
2016-01-22 03:39:07 +00:00
Rich Felker 513c043694 overhaul powerpc atomics for new atomics framework
previously powerpc had a_cas defined in terms of its native ll/sc
style operations, but all other atomics were defined in terms of
a_cas. instead define a_ll and a_sc so the compiler can generate
optimized versions of all the atomic ops and perform better inlining
of a_cas.

extracting the result of the sc (stwcx.) instruction is rather awkward
because it's natively stored in a condition flag, which is not
representable in inline asm. but even with this limitation the new
code still seems significantly better.
2016-01-22 02:58:32 +00:00
Rich Felker 16b55298dc clean up x86_64 (and x32) atomics for new atomics framework
this commit mostly makes consistent things like spacing, function
ordering in atomic_arch.h, argument names, use of volatile, etc.
a_ctz_l was also removed from x86_64 since atomic.h provides it
automatically using a_ctz_64.
2016-01-22 00:53:09 +00:00
Rich Felker e24984efd5 clean up i386 atomics for new atomics framework
this commit mostly makes consistent things like spacing, function
ordering in atomic_arch.h, argument names, use of volatile, etc. the
fake 64-bit and/or atomics are also removed because the shared
atomic.h does a better job of implementing them; it avoids making two
atomic memory accesses when only one 32-bit half needs to be touched.

no major overhaul is needed or possible because x86 actually has
native versions of all the usual atomic operations, rather than using
ll/sc or needing cas loops.
2016-01-22 00:16:53 +00:00
Rich Felker 369b22f9c4 overhaul mips atomics for new atomics framework 2016-01-22 00:10:40 +00:00
Rich Felker e617b9eea9 move arm-specific translation units out of arch/arm/src, to src/*/arm
this is possible with the new build system that allows src/*/$(ARCH)/*
files which do not shadow a file in the parent directory, and yields a
more logical organization. eventually it will be possible to remove
arch/*/src from the build system.
2016-01-22 00:02:21 +00:00
Rich Felker 397f0a6a7d overhaul arm atomics for new atomics framework
switch to ll/sc model so that new atomic.h can provide optimized
versions of all the atomic primitives without needing an ll/sc loop
written in asm for each one.

all isa levels which use ldrex/strex now use the inline ll/sc model
even if the type of barrier to use is not known until runtime (v6).
the cas model is only used for arm v5 and earlier, and it has been
optimized to make the call via inline asm with custom constraints
rather than as a C function call.
2016-01-21 23:30:30 +00:00
Rich Felker aa0db4b5d0 overhaul aarch64 atomics for new atomics framework 2016-01-21 19:50:55 +00:00
Rich Felker 61b1e75f7d overhaul sh atomics for new atomics framework, add j-core cas.l backend
sh needs runtime-selected atomic backends since there are a number of
supported models that use non-forwards-compatible (non-smp-compatible)
atomic mechanisms. previously, the code paths for this were highly
inefficient since they involved C function calls with multiple
branches in the callee and heavy spills in the caller. the new code
performs calls the runtime-selected asm fragment from inline asm with
extremely minimal clobbers, rather than using a function call.

for the sh4a case where the atomic mechanism is known and there is no
forward-compatibility issue, the movli.l and movco.l instructions are
provided as a_ll and a_sc, allowing the new shared atomic.h to
generate efficient inline versions of all the basic atomic operations
without needing a cas loop.
2016-01-21 19:43:04 +00:00
Rich Felker 1315596b51 refactor internal atomic.h
rather than having each arch provide its own atomic.h, there is a new
shared atomic.h in src/internal which pulls arch-specific definitions
from arc/$(ARCH)/atomic_arch.h. the latter can be extremely minimal,
defining only a_cas or new ll/sc type primitives which the shared
atomic.h will use to construct everything else.

this commit avoids making heavy changes to the individual archs'
atomic implementations. definitions which are identical or
near-identical to what the new shared atomic.h would produce have been
removed, but otherwise the changes made are just hooking up the
arch-specific files to the new infrastructure. major changes to take
advantage of the new system will come in subsequent commits.
2016-01-21 19:08:54 +00:00
Rich Felker ce3e24eaae fix global visibility (vis.h) support for out-of-tree builds
commit 2f853dd6b9 failed to change the
test for -include vis.h support to use $srcdir, so vis.h was always
disabled by configure for out-of-tree builds.
2016-01-20 19:43:37 +00:00
Khem Raj d1b29c2a54 exclude vis.h when compiling assembly files
otherwise C declarations are included into preprocessed (.S) asm
source files, producing errors from the assembler.
2016-01-20 19:42:21 +00:00
Rich Felker 4fcc7eb51c simplify "make clean" and remove unneeded lib dir from tree
the lib dir is automatically created if needed by the out-of-tree
build logic, and now that all generated files are in obj and lib,
deleting them is much simpler. using "rm -rf" is also more thorough,
as it picks up object files that were left around from source files
that no longer exist or which are no longer to be used because an
arch-specific replacement file was added or removed.
2016-01-20 04:01:05 +00:00
Rich Felker ada4798df0 deduplicate compiler invocation command line in makefile
also clean up duplication of CFLAGS passing to assembler.
2016-01-20 02:58:29 +00:00
Rich Felker 80de11bc6b remove outdated/incorrect comment about AS_CMD from makefile 2016-01-20 02:52:39 +00:00