Commit Graph

165 Commits

Author SHA1 Message Date
Brooks Davis
db19a093bb Remove MD __sys_* private symbols.
No references to any of these exist in the tree. The list was also
erratic with different architectures exporting different things
(arm64 and riscv exported none).

Reviewed by:	kib
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D18425
2018-12-05 00:46:09 +00:00
Mark Johnston
9f9c9b22ec Reimplement brk() and sbrk() to avoid the use of _end.
Previously, libc.so would initialize its notion of the break address
using _end, a special symbol emitted by the static linker following
the bss section.  Compatibility issues between lld and ld.bfd could
cause the wrong definition of _end (libc.so's definition rather than
that of the executable) to be used, breaking the brk()/sbrk()
interface.

Avoid this problem and future interoperability issues by simply not
relying on _end.  Instead, modify the break() system call to return
the kernel's view of the current break address, and have libc
initialize its state using an extra syscall upon the first use of the
interface.  As a side effect, this appears to fix brk()/sbrk() usage
in executables run with rtld direct exec, since the kernel and libc.so
no longer maintain separate views of the process' break address.

PR:		228574
Reviewed by:	kib (previous version)
MFC after:	2 months
Differential Revision:	https://reviews.freebsd.org/D15663
2018-06-04 19:35:15 +00:00
Brooks Davis
87385baff6 Replace MD assembly exect() with a portable version.
Originally, on the VAX exect() enable tracing once the new executable
image was loaded.  This was possible because tracing was controllable
through user space code by setting the PSL_T flag.  The following
instruction is a system call that activated tracing (as all
instructions do) by copying PSL_T to PSL_TP (trace pending).  The
first instruction of the new executable image would trigger a trace
fault.

This is not portable to all platforms and the behavior was replaced with
ptrace(PT_TRACE_ME, ...) since FreeBSD forked off of the CSRG repository.
Platforms either incorrectly call execve(), trigger trace faults inside
the original executable, or do contain an implementation of this
function.

The exect() interfaces is deprecated or removed on NetBSD and OpenBSD.

Submitted by:	Ali Mashtizadeh <ali@mashtizadeh.com>
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D14989
2018-04-12 18:23:14 +00:00
Brooks Davis
047a2ef697 Remove caching from getlogin(2).
This caching has existed since the CSRG import, but serves no obvious
purpose. Sure, setlogin() is called rarely, but calls to getlogin()
should also be infrequent. The required invalidation was not
implemented on aarch64, arm, mips, amd riscv so updates would never
occur if getlogin() was called before setlogin().

Reported by:	Ali Mashtizadeh <ali@mashtizadeh.com>
Reviewed by:	kib
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D14965
2018-04-06 17:17:34 +00:00
Marius Strobl
41fc6f680b o Let rtld(1) set up psABI user trap handlers prior to executing the
objects' init functions instead of doing the setup via a constructor
  in libc as the init functions may already depend on these handlers
  to be in place. This gets us rid of:
  - the undefined order in which libc constructors as __guard_setup()
    and jemalloc_constructor() are executed WRT __sparc_utrap_setup(),
  - the requirement to link libc last so __sparc_utrap_setup() gets
    called prior to constructors in other libraries (see r122883).
  For static binaries, crt1.o still sets up the user trap handlers.
o Move misplaced prototypes for MD functions in to the MD prototype
  section of rtld.h.
o Sprinkle nitems().
2018-02-03 23:14:11 +00:00
Eitan Adler
d52a982ea8 lib: Fix several typos and minor errors
- duplicate words
- typos
- references to old versions of FreeBSD

Reviewed by:	imp, benno
2017-12-27 03:23:41 +00:00
Pedro F. Giffuni
d915a14ef0 libc: further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using mis-identified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.
2017-11-25 17:12:48 +00:00
Pedro F. Giffuni
8a16b7a18f General further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.
2017-11-20 19:49:47 +00:00
Brooks Davis
13f2393362 Correct an misunderstanding of MDSRCS.
MDSRCS it intended to allow assembly versions of funtions with C
implementations listed in MISRCS. The selection of the correct
machdep_ldis?.c for a given architecture does not follow this pattern
and the file should be added to SRCS directly.

Reviewed by:	emaste, imp, jhb
MFC after:	1 week
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D9841
2017-03-02 17:07:28 +00:00
Brooks Davis
9fe44df287 Correct MDSRCS use in <arch>/string/Makefile.inc.
- Remove .c files which duplicate entries in MISRCS.
- Use the same, less merge conflict prone style in all cases.
- Use MDSRCS for mips (.c and .S files both ended up in SRCS).
- Remove pointless sparc64 Makefile.inc.
- Remove uninformative foreign VCS ID entries.

Reviewed by:	emaste, imp, jhb
MFC after:	1 week
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D9841
2017-03-02 17:05:52 +00:00
Warner Losh
fbbd9655e5 Renumber copyright clause 4
Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by:	Jan Schaumann <jschauma@stevens.edu>
Pull Request:	https://github.com/freebsd/freebsd/pull/96
2017-02-28 23:42:47 +00:00
Brooks Davis
aec2fba60f Reduce duplicate NOASM and PSEUDO definitions
The initial value of NOASM is nearly the same in all cases and the
initial value of PSEUDO is the same in all cases so reduce duplication
(and hopefully, future merge conflicts) by machine independent defaults.

Also document the PSEUDO variable.

Reviewed by:	jhb, kib
Obtained from:	CheriBSD
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D7820
2016-09-08 22:38:20 +00:00
Konstantin Belousov
afd3e268d2 Rewrite ptrace(2) wrappers in C.
Besides removing hand-translation to assembler, this also adds missing
wrappers for arm64 and risc-v.

Reviewed by:	emaste, jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D7694
2016-08-29 18:47:51 +00:00
George V. Neville-Neil
5cba398b0c Remove unusedd and obsolete openbsd_poll system call. (Phase 1)
Reported by:	brooks
Reviewed by:	brooks,jhb
Differential Revision:	https://reviews.freebsd.org/D7548
2016-08-18 10:50:40 +00:00
Brooks Davis
b60998c633 Replace use of the pipe(2) system call with pipe2(2) with a zero flags
value.

This eliminates the need for machine dependant assembly wrappers for
pipe(2).

It also make passing an invalid address to pipe(2) return EFAULT rather
than triggering a segfault.  Document this behavior (which was already
true for pipe2(2), but undocumented).

Reviewed by:	andrew
Approved by:	re (gjb)
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D6815
2016-06-22 21:11:27 +00:00
Pedro F. Giffuni
32223c1b7d libc: spelling fixes.
Mostly on comments.
2016-04-30 01:24:24 +00:00
Ed Maste
a38e4f5cc6 libc: stop exporting cerror
i386 stopped exporting .cerror in r240152, and likewise for amd64 in
r240178. It is not used by other libraries on any platform, so apply
the same change to the remaining architectures.

Reviewed by:	jhibbits, jilles
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D5774
2016-03-30 14:42:09 +00:00
Ed Maste
dae2d550d6 libc: stop exporting curbrk and minbrk in the private namespace
They are not used anywhere else in the base system and are an internal
implementation detail that does not need to be exposed.

Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D5728
2016-03-24 18:47:19 +00:00
Baptiste Daroussin
4ba17eaff6 Fix unused-but-set-variable
Spotted by:	gcc 5.2
2015-11-15 20:44:22 +00:00
Craig Rodrigues
6874645fa9 Add include for declaration of _set_tp(). Eliminates -Wmissing-prototypes warnings. 2015-09-20 04:59:01 +00:00
Konstantin Belousov
0538aafc41 The lseek(2), mmap(2), truncate(2), ftruncate(2), pread(2), and
pwrite(2) syscalls are wrapped to provide compatibility with pre-7.x
kernels which required padding before the off_t parameter.  The
fcntl(2) contains compatibility code to handle kernels before the
struct flock was changed during the 8.x CURRENT development.  The
shims were reasonable to allow easier revert to the older kernel at
that time.

Now, two or three major releases later, shims do not serve any
purpose.  Such old kernels cannot handle current libc, so revert the
compatibility code.

Make padded syscalls support conditional under the COMPAT6 config
option.  For COMPAT32, the syscalls were under COMPAT6 already.

Remove WITHOUT_SYSCALL_COMPAT build option, which only purpose was to
(partially) disable the removed shims.

Reviewed by:	jhb, imp (previous versions)
Discussed with:	peter
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2015-04-18 21:50:13 +00:00
Ed Maste
541236cf60 libc: Eliminate duplicate copies of __vdso_gettc.c
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D2152
2015-04-02 21:18:11 +00:00
Marius Strobl
aed116911d Unbreak sparc64 after r276630 by calling __sparc_sigtramp_setup signal
trampoline as part of the MD __sys_sigaction again.

Submitted by:	kib (initial versions)
MFC after:	3 days
2015-02-16 22:13:03 +00:00
Ed Maste
4b12fb6103 Remove duplicate copies of trivial getcontextx.c
Only i386 and amd64 provide a non-trivial __getcontextx(). Use a common
trivial implementation in gen/ for other architectures, rather than
copying the file to each MD subdirectory.

Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D1472
2015-01-12 18:13:38 +00:00
Warner Losh
a5fc5b6223 Convert from WITHOUT_SYSCALL_COMPAT to MK_SYSCALL_COMPAT. 2014-04-05 17:54:43 +00:00
Marcel Moolenaar
8876613dc5 Replace use of ${.CURDIR} by ${LIBC_SRCTOP} and define ${LIBC_SRCTOP}
if not already defined. This allows building libc from outside of
lib/libc using a reach-over makefile.

A typical use-case is to build a standard ILP32 version and a COMPAT32
version in a single iteration by building the COMPAT32 version using a
reach-over makefile.

Obtained from:	Juniper Networks, Inc.
2014-03-04 02:19:39 +00:00
Dimitry Andric
19e61966d6 In lib/libc/sparc64/sys/__sparc_utrap_setup.c, avoid an error about
passing a pointer to a const object to sysarch().
2014-02-20 23:02:42 +00:00
Eitan Adler
7a22215c53 Fix undefined behavior: (1 << 31) is not defined as 1 is an int and this
shifts into the sign bit.  Instead use (1U << 31) which gets the
expected result.

This fix is not ideal as it assumes a 32 bit int, but does fix the issue
for most cases.

A similar change was made in OpenBSD.

Discussed with:	-arch, rdivacky
Reviewed by:	cperciva
2013-11-30 22:17:27 +00:00
Marius Strobl
85338755c1 Prefix the alias macros for members of struct __mcontext with an underscore
in order to avoid a clash in the net80211 code.
2013-07-12 14:24:52 +00:00
Konstantin Belousov
55a1911ef2 The getcontext() from the __fillcontextx() call in the
check_deferred_signal() returns twice, since handle_signal() emulates
the return from the normal signal handler by sigreturn(2)ing the
passed context.  Second return is performed on the destroyed stack
frame, because __fillcontextx() has already returned.  This causes
undefined and bad behaviour, usually the victim thread gets SIGSEGV.

Avoid nested frame and the need to return from it by doing direct call
to getcontext() in the check_deferred_signal() and using a new private
libc helper __fillcontextx2() to complement the context with the
extended CPU state if the deferred signal is still present.

The __fillcontextx() is now unused, but is kept to allow older
libthr.so to be used with the new libc.

Mark __fillcontextx() as returning twice [1].

Reported by:	pgj
Pointy hat to:	kib
Discussed with:	dim
Tested by:	pgj, dim
Suggested by:	jilles [1]
MFC after:	1 week
2013-05-28 04:54:16 +00:00
Konstantin Belousov
150facd256 Rework the __vdso_* symbols attributes to only make the symbols weak,
but use normal references instead of weak.  This makes the statically
linked binaries to use fast gettimeofday(2) by forcing the linker to
resolve references and providing the neccessary functions.

Reported by:	bde
Tested by:	marius (sparc64)
MFC after:	2 weeks
2013-01-30 12:48:16 +00:00
Konstantin Belousov
754f1c1e63 Make the sys/ucontext.h self-contained by changing the return type
of __getcontextx_size(3) from size_t to int.

PR:	ports/164654
MFC after:	1 month
2012-02-01 13:33:53 +00:00
Konstantin Belousov
2b1de0afd1 Add API for obtaining extended machine context states that cannot be
fit into existing mcontext_t.

On i386 and amd64 do return the extended FPU states using
getcontextx(3). For other architectures, getcontextx(3) returns the
same information as getcontext(2).

Tested by:  pho
MFC after:  1 month
2012-01-21 18:00:28 +00:00
David Schultz
8ff9d52cd0 Computations on NaNs are supposed to return one of the input NaNs unchanged.
Fix a few places in the sparc64 floating-point emulator where this wasn't
being handled properly.

Submitted by:	bde
2012-01-16 04:09:45 +00:00
David Schultz
6232589aeb Replace a proliferation of buggy MD implementations of modf() with a
working MI one.  The MI one only needs to be overridden on machines
with non-IEEE754 arithmetic.  (The last supported one was the VAX.)
It can also be overridden if someone comes up with a faster one that
actually passes the regression tests -- but this is harder than it sounds.
2011-10-21 06:40:36 +00:00
Ed Schouten
3a28b8a49f Fix whitespace inconsistencies found in homegrown Symbol.maps. 2011-10-07 15:05:24 +00:00
Attilio Rao
4b547324c0 Disconnect sun4v architecture from the three.
Some files keep the SUN4V tags as a code reference, for the future,
if any rewamped sun4v support wants to be added again.

Reviewed by:	marius
Tested by:	sbruno
Approved by:	re
2011-05-14 01:53:38 +00:00
Marius Strobl
be05bc3ffb Avoid aliasing which leads to incorrect results when compiling with the
default strict aliasing rules.

PR:		144900
Submitted by:	Peter Jeremy
MFC after:	3 days
2010-03-21 13:18:08 +00:00
Marius Strobl
b28ad3ebc9 - While SPARC V9 allows tininess to be detected either before or after
rounding (impl. dep. #55), the SPARC JPS1 responsible for SPARC64 and
  UltraSPARC processors defines that in all cases tinyness is detected
  before rounding, therefore rounding up to the smallest normalised
  number should set the underflow flag.
- If an infinite result is rounded down, the result should have an
  exponent 1 less than the value for infinity.

PR:		144900
Submitted by:	Peter Jeremy
MFC after:	3 days
2010-03-20 22:32:13 +00:00
Marius Strobl
bd2ec8519e Division should take both arguments' signs into account when the
the dividend is infinity or zero and the divisor is not the same.

PR:		144900
Submitted by:	Peter Jeremy
MFC after:	3 days
2010-03-20 22:12:15 +00:00
Marius Strobl
484bacf4b9 FPU_DEBUG requires <stdio.h>.
PR:		144900
Submitted by:	Peter Jeremy
MFC after:	3 days
2010-03-20 21:27:44 +00:00
Marius Strobl
4dda9dfd81 Ensure that __fpu_ftox() both returns the high bits and res[1] contains
the low bits also in the default case.

PR:		144900
Obtained from:	OpenBSD
MFC after:	3 days
2010-03-20 21:15:56 +00:00
Marius Strobl
564b3fffdd - Remove a bogus forward declaration.
- Fix whitespace.
2010-03-20 21:04:47 +00:00
Marius Strobl
7e0e1004f3 Fix a typo in r204974 so that FTYPE_LNG matches the initialisers of
the opmask array.

Pointed out by:	Peter Jeremy
2010-03-11 07:46:17 +00:00
Marius Strobl
ff2f66ea79 - The OPSZ macro actually only does the right thing for int32 and int64
operands but not for double and extended double ones. Instead of trying
  to fix the macro just nuke it and unroll the loops in the correct way
  though as extended double operands turn out to be the only special case.
- For FxTO{s,d,q} the source operand is int64 so rs2 has to be re-decoded
  after setting type accordingly as it's generally decoded using the low
  2 bits as the type, which are 0 for these three instructions.
- Similarly, in case of F{s,d,q}TOx the target is int64 so rd has to be
  re-decoded using not only the operand mask appropriate for int64 but
  also the correct register number encoding.
- Use const where appropriate.
- Wrap long lines.

Submitted by:	Peter Jeremy (partly)
MFC after:	3 days
2010-03-10 19:55:48 +00:00
Joel Dahl
2598954edc The NetBSD Foundation has granted permission to remove clause 3 and 4 from
their software.

Obtained from:	NetBSD
2010-03-03 17:07:02 +00:00
Ed Schouten
dc428c2ffe Remove unneeded stdlib directories.
It's not necessary to add stdlib directories for each architecture, even
if the architecture doesn't implement any files of its own.

Submitted by:	Christoph Mallon
2009-06-23 14:11:41 +00:00
Roman Divacky
b1e58dd43e Provide a type for the argument.
Approved by:	kib (mentor)
2009-02-02 21:51:52 +00:00
Ed Schouten
a1b5a8955e Mark uname(), getdomainname() and setdomainname() with COMPAT_FREEBSD4.
Looking at our source code history, it seems the uname(),
getdomainname() and setdomainname() system calls got deprecated
somewhere after FreeBSD 1.1, but they have never been phased out
properly. Because we don't have a COMPAT_FREEBSD1, just use
COMPAT_FREEBSD4.

Also fix the Linuxolator to build without the setdomainname() routine by
just making it call userland_sysctl on kern.domainname. Also replace the
setdomainname()'s implementation to use this approach, because we're
duplicating code with sysctl_domainname().

I wasn't able to keep these three routines working in our
COMPAT_FREEBSD32, because that would require yet another keyword for
syscalls.master (COMPAT4+NOPROTO). Because this routine is probably
unused already, this won't be a problem in practice. If it turns out to
be a problem, we'll just restore this functionality.

Reviewed by:	rdivacky, kib
2008-11-09 10:45:13 +00:00
David Schultz
10a465e525 Fix some bugs that caused sparc64's quad precision sqrt to get
the wrong answer for virtually all inputs.

Thanks to remko for access to a sparc64 box for testing.
2008-04-12 03:10:13 +00:00