Commit Graph

13367 Commits

Author SHA1 Message Date
Nathan Whitehorn
f61ce56845 Allow ABIs to provide their own LIBC_ARCH in a more generic way. As a side
effect, this fixes the build on powerpc64.

Reviewed by:	imp
2010-08-25 20:48:24 +00:00
Warner Losh
bff351d7fe Fix an accidental sed... 2010-08-24 21:28:34 +00:00
Warner Losh
2c0959ae6b Powerpc is special here. powerpc and powerpc64 use different ABIs, so
their implementations aren't in the same files.  Introduce LIBC_ARCH
and use that in preference to MACHINE_CPUARCH.  Tested by amd64 and
powerpc64 builds (thanks nathanw@)
2010-08-24 20:54:43 +00:00
Nathan Whitehorn
f4fbf9c859 Unify 32-bit and 64-bit PowerPC libthr support. This reduces code
duplication, and simplifies the TBEMD import.

Requested by:	imp
2010-08-24 20:50:08 +00:00
Warner Losh
2bef81cf3a Change the logic here to match Makefile.inc1. Having it in two places
suggests an opportunity for refactoring :)

Submitted by:	nathanw@
2010-08-24 16:35:26 +00:00
Konstantin Belousov
3e3fbd3f25 Remove extra FreeBSD tag.
MFC after:	3 days
2010-08-24 13:02:22 +00:00
Konstantin Belousov
da2a0df59c Move the __stack_chk_fail_local@FBSD_1.0 compat symbol definition into
the separate .o for libc_pic.a. This prevents rtld from making the
symbol global.

Putting the stack_protector_compat.c into the public domain acknowledged
by kan.

Reviewed by:	kan
MFC after:	2 weeks
2010-08-24 12:58:54 +00:00
Konstantin Belousov
247a32fac5 Remove unused source.
MFC after:	2 weeks
2010-08-24 11:55:25 +00:00
Konstantin Belousov
47536ff629 The __hidden definition is provided by sys/cdefs.h.
MFC after:	2 weeks
2010-08-24 11:54:48 +00:00
David Xu
5cf2219535 Add wrapper for setcontext() and swapcontext(), the wrappers
unblock SIGCANCEL which is needed by thread cancellation.
2010-08-24 09:57:06 +00:00
Warner Losh
25faff346c MFtbemd:
Prefer MACHNE_CPUARCH to MACHINE_ARCH in most contexts where you want
to test of all the CPUs of a given family conform.
2010-08-23 22:24:11 +00:00
Konstantin Belousov
ea246b6369 On shared object unload, in __cxa_finalize, call and clear all installed
atexit and __cxa_atexit handlers that are either installed by unloaded
dso, or points to the functions provided by the dso.

Use _rtld_addr_phdr to locate segment information from the address of
private variable belonging to the dso, supplied by crtstuff.c. Provide
utility function __elf_phdr_match_addr to do the match of address against
dso executable segment.

Call back into libthr from __cxa_finalize using weak
__pthread_cxa_finalize symbol to remove any atfork handler which
function points into unloaded object.

The rtld needs private __pthread_cxa_finalize symbol to not require
resolution of the weak undefined symbol at initialization time. This
cannot work, since rtld is relocated before sym_zero is set up.

Idea by:	kan
Reviewed by:	kan (previous version)
MFC after:	3 weeks
2010-08-23 15:38:02 +00:00
Konstantin Belousov
e048186a62 Introduce implementation-private rtld interface _rtld_addr_phdr, which
fills struct dl_phdr_info for the shared object that contains the
specified address, if any.

Idea and reviewed by:	kan
MFC after:	3 weeks
2010-08-23 15:27:03 +00:00
Konstantin Belousov
aeaffd647e Style.
MFC after:	3 days
2010-08-23 15:18:35 +00:00
Dag-Erling Smørgrav
b8370f59bd UTFize my name. 2010-08-22 11:48:32 +00:00
Rui Paulo
029a737371 Don't link drti.o with libelf_pic.a. This means that all software with
userland SDT probes must be linked with libelf explicitly.

Requested by:	kib
Sponsored by:	The FreeBSD Foundation
2010-08-21 17:29:59 +00:00
Rui Paulo
2aedda247b Modify clang so that when TOOLS_PREFIX is defined we register the
CLANG_PREFIX macro. This changes the default header search path when we
are building clang as part of cross-tools.

Submitted by:	Dimitry Andric <dimitry at andric.com>
Reviewed by:	freebsd-current
2010-08-21 15:46:33 +00:00
Rui Paulo
9329096b80 Install a PIC libelf. This will be needed by the DTrace runtime
instrumentation object (dtri.o).

Sponsored by:	The FreeBSD Foundation
2010-08-21 10:40:12 +00:00
David Xu
82746ea546 Reduce redundant code.
Submitted by: kib
2010-08-20 13:42:48 +00:00
David Xu
635f917a9d In current implementation, thread cancellation is done in signal handler,
which does not know what is the state of interrupted system call, for
example, open() system call opened a file and the thread is still cancelled,
result is descriptor leak, there are other problems which can cause resource
leak or undeterminable side effect when a thread is cancelled. However, this
is no longer true in new implementation.

  In defering mode, a thread is canceled if cancellation request is pending and
later the thread enters a cancellation point, otherwise, a later
pthread_cancel() just causes SIGCANCEL to be sent to the target thread, and
causes target thread to abort system call, userland code in libthr then checks
cancellation state, and cancels the thread if needed. For example, the
cancellation point open(), the thread may be canceled at start,
but later, if it opened a file descriptor, it is not canceled, this avoids
file handle leak. Another example is read(), a thread may be canceled at start
of the function, but later, if it read some bytes from a socket, the thread
is not canceled, the caller then can decide if it should still enable cancelling
or disable it and continue reading data until it thinks it has read all
bytes of a packet, and keeps a protocol stream in health state, if user ignores
partly reading of a packet without disabling cancellation, then second iteration
of read loop cause the thread to be cancelled.
An exception is that the close() cancellation point always closes a file handle
despite whether the thread is cancelled or not.

  The old mechanism is still kept, for a functions which is not so easily to
fix a cancellation problem, the rough mechanism is used.

Reviewed by: kib@
2010-08-20 05:15:39 +00:00
David Xu
719863239e According to specification, function fcntl() is a cancellation point only
when cmd argument is F_SETLKW.
2010-08-20 04:15:05 +00:00
Konstantin Belousov
2793b01844 Use aux vector to get values for SSP canary, pagesize, pagesizes array,
number of host CPUs and osreldate.

This eliminates the last sysctl(2) calls from the dynamically linked image
startup.

No objections from:	kan
Tested by:	marius (sparc64)
MFC after:	1 month
2010-08-17 09:13:26 +00:00
David Xu
cdcffc3f1c Tweak code a bit to be POSIX compatible, when a cancellation request
is acted upon, or when a thread calls pthread_exit(), the thread first
disables cancellation by setting its cancelability state to
PTHREAD_CANCEL_DISABLE and its cancelability type to
PTHREAD_CANCEL_DEFERRED. The cancelability state remains set to
PTHREAD_CANCEL_DISABLE until the thread has terminated.

It has no effect if a cancellation cleanup handler or thread-specific
data destructor routine changes the cancelability state to
PTHREAD_CANCEL_ENABLE.
2010-08-17 02:50:12 +00:00
Joel Dahl
c2025a7660 Fix typos, spelling, formatting and mdoc mistakes found by Nobuyuki while
translating these manual pages.  Minor corrections by me.

Submitted by:	Nobuyuki Koganemaru <n-kogane@syd.odn.ne.jp>
2010-08-16 15:18:30 +00:00
Dag-Erling Smørgrav
35305a8dc1 In setusercontext(), do not apply user settings unless running as the
user in question (usually but not necessarily because we were called
with LOGIN_SETUSER).  This plugs a hole where users could raise their
resource limits and expand their CPU mask.

MFC after:	3 weeks
2010-08-16 11:32:20 +00:00
Dag-Erling Smørgrav
f4fda7679a Old patch I had lying around: clean up and use stpcpy(3) instead of
sprintf(3).
2010-08-16 11:22:12 +00:00
Dag-Erling Smørgrav
a2e0c5ae31 Further simplify the code, and update the manpage.
Submitted by:	Christoph Mallon <christoph.mallon@gmx.de>
2010-08-15 18:32:06 +00:00
Hajimu UMEMOTO
2db99256b1 Correct the return code from _dns_gethostby*() to correspond
with h_errno.

Obtained from:	NetBSD
MFC after:	2 weeks
2010-08-15 16:28:08 +00:00
Dag-Erling Smørgrav
b6fbd4d50d no-op commit to note that the example given in the previous commit is
a very bad one, since the shift does not actually overflow.  This is
a better example (assuming uint64_t = unsigned long long):

  ~0LLU >> 9             =   0x7fffffffffffffLLU
  ~0LLU >> 9 << 10       = 0xfffffffffffffc00LLU
  ~0LLU >> 9 << 10 >> 10 =   0x3fffffffffffffLLU
2010-08-15 14:55:32 +00:00
Dag-Erling Smørgrav
1035d74025 Fix the overflow test. It is possible for the result of an
overflowing shift to be larger than the original value, e.g.

         (uint64_t)1 << 53 = 0x20000000000000
 ((uint64_t)1 << 53) << 10 = 0x8000000000000000
2010-08-15 14:50:03 +00:00
Dag-Erling Smørgrav
bbb2703b4f Simplify expand_number() by combining the (unrolled) loop with the
switch.  Since expand_number() does not accept negative numbers, switch
from int64_t to uint64_t; this makes it easier to check for overflow.

MFC after:	3 weeks
2010-08-14 14:34:36 +00:00
Hajimu UMEMOTO
225edeac51 - When there is no room for returning the result, nss backend
have to return ERANGE and terminate with NS_RETURN.
- When gethostbyname_r(3) and the friends end with an error,
  set errno to the value nss backend returns, and return errno
  value.

PR:		kern/131623
MFC after:	2 weeks
2010-08-13 06:39:54 +00:00
Will Andrews
4be3feb212 Fix buildworld -DNO_CLEAN when using with Perforce, which marks files as
read-only by default, meaning files copied can't be overwritten next time.

Reviewed by:	imp
Approved by:	ken (mentor)
2010-08-12 20:46:49 +00:00
Kai Wang
f4717fa913 Add translation support for section type SHT_SUNW_dof.
Submitted by:	rpaulo
MFC after:	2 weeks
2010-08-11 19:59:31 +00:00
Rui Paulo
4c74b2455d Several fixes for libproc:
o return the correct status in proc_wstatus()
o proc_read takes a void *
o correctly allocate the objs structure array

Sponsored by:	The FreeBSD Foundation
2010-08-11 17:33:26 +00:00
Ed Schouten
83dd4eeb78 Small style(9) fix: use tabs instead of spaces. 2010-08-08 08:19:23 +00:00
Ed Schouten
29b63864a2 Remove unneeded functions from libcompat.
Erwin fired up a ports build a couple of weeks ago and it seems the
following functions are not used by any of the 20k ports we have, which
makes me believe they don't have any purpose. Just remove them.
2010-08-06 20:13:36 +00:00
Joel Dahl
f6ac23919b Fix typos and spelling mistakes. 2010-08-06 14:33:42 +00:00
Andrey A. Chernov
01e14bff35 Comment out IEEE Std 1003.1-2001 conformance proclaimed too early,
see problems described in the comment to:
http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/128933
2010-08-05 01:39:25 +00:00
Joel Dahl
56b8fbdbe3 Fix typo. 2010-08-03 18:29:58 +00:00
Joel Dahl
799162a628 Spelling fixes. 2010-08-03 17:40:09 +00:00
Joel Dahl
edfa427cf1 Spelling fixes. 2010-08-02 16:01:45 +00:00
Ulrich Spörlein
b919e6378a mdoc policing: use consistent section ordering, fix quotes and trailing
whitespace

Approved by:	rpaulo
2010-08-02 15:15:24 +00:00
Ulrich Spörlein
3d05ebbcf8 mdoc: remove unbalanced quotes 2010-08-02 13:11:41 +00:00
Ulrich Spörlein
c0da74038d mdoc: make sure to pass at least one argument to quotation macros 2010-08-02 13:11:35 +00:00
Rui Paulo
271e7c594b Disable all warnings when building gdtoa. This allows building libc with
clang.
The general idea is that the vendor will not accept our compilation
patches and so disabling the warnings is the best way to go as it makes
future imports bearable.

Submitted by:	Dimitry Andric <dimitry at andric.com>
Discussed with:	das
2010-08-01 12:35:01 +00:00
Rui Paulo
a7c2001059 Use CFLAGS and LDFLAGS when compiling mkmagic. This ensures that all the
correct flags are being used (esp. NO_WERROR wrt clang).

Submitted by:	Dimitry Andric <dimitry at andric.com>
Reviewed by:	ru
2010-08-01 12:10:32 +00:00
Rui Paulo
fe0c8f8973 Revert SHLIB_MAJOR to 2.
As discussed with kan@, since DTrace is the only consumer of libproc
right now, there's no need for a major shlib bump.
2010-07-31 17:14:54 +00:00
Rui Paulo
fb05b66676 Build librtld_db.
Sponsored by:	The FreeBSD Foundation
2010-07-31 16:12:47 +00:00
Rui Paulo
295790277a Bump the shared library major version due to ABI conflicts.
Sponsored by:	The FreeBSD Foundation
2010-07-31 16:11:11 +00:00