One macro based on GCC visibility functions was already defined,
__exported. However, it was marked as available for all GCC versions
when it fact it was introduced with gcc 4.0.

There was no macro for hidden visibility attributes, so the macros
__dso_hidden and __dso_public were borrowed from NetBSD. __dso_public
is an alias for __exported. The definition for all three macros were
made on the condition that the gcc version used is 4.0 or later.

The boot2_32.ld loader file needs to come in at 7680 bytes or less, while
boot2_64.ld can be a little bigger with a 14848 byte threshold. The
32-bit version has the least memory margin. Using the base gcc 4.4
compiler, it only has 396 bytes to spare.

Using updates from FreeBSD buys 292 additional bytes when built by the
base compiler. This additional space may be useful for building world
with clang which may have slightly larger executables.

SVN 218745 (16 FEB 2011)
SHRINK: Remove reading of symbols from a.out loaded files. This
functionality was left over from the early FreeBSD 3.x days to
support kernels in a.out format which never applied to DragonFly.
Removing it saves around 100 bytes. bootinfo.bi_esymtab was also
relocated to the ELF section rather than aways being set.

SVN 220392 (06 APR 2011)
BUG: Move getc() before xgetc() so gcc does not emit a warning about
function having no body.

Minor changes from John Marino
==============================
Created RBF_NOINTR and RBF_PROBEKBD macros for consist style.
Removed "#if 0" sections to clean up.
returned "static" back to drvread body (was still in prototype).
Changed xputc() to return the char rather than void (matches FreeBSD),

Starting with gcc 4.5, sbin/restore would break on interactive.c with
the complaint that the designated length of the storage array within
the adirent union structure was not constant. After three previous
proposals on the best way to fix it, this is the one requiring the
least code change. (Don't count the spelling correction!)

This was the last place the breaks using WORLD_CCVER=gcc46. The
kernel builds cleanly. Both the gcc46-built world and kernel load
and function normally.

Note that it still might crash or stop working, so it's still
experimental. We're bringing it anyway because several people showed
interest in continuing to work on it and so it doesn't rot outside
our tree, gets at least built with world/kernel, etc.

A big sticking point with getting gcc46 to successfully buildworld was
getting boot2 to come in at 7680 bytes or less. Unmodified it was
weighing in 784 bytes too much. Every applying several byte-reducing
changes to it from FreeBSD only knocked off about 380 bytes.

Comparing the assembly dumps between versions built by the base
compiler and gcc46 didn't reveal that much, but using the readelf
utility on both did. GCC 4.6 was embedding the .eh_frame section
to the object file generated from boot2.c which was adding over 1900
bytes to it.

After adding three command line switches to the makefile, the
exception handler section is prohibited from building. There are
4968 bytes still available, down from 4988 bytes seen with the base
compiler. The updates from FreeBSD can be applied later to free up
more memory but for now it's not required.

Currently WORLD_CCVER=gcc46 will break on gcc4.1, include/rpcsvc, and is
not recognized by libc. This commit will fix that. The nis.x fix is the
least understood as the gnatcpp seems not to like multiline macros when
used with rpcgen.

There will be a slight performance hit with having to make two calls to
gnatc++ before every real call in order to use gnat-aux's c++ library
rather than the base systems gcc 4.4 c++ library. The alternative is
hardcoding these values as a function of arch which is less appealing.

* SIGIO was being installed with SA_NODEFER, resulting in situations
under heavy network loads where multiple SIGIOs could stack and cause
a stack overflow. This often resulted in the sendsig code in the kernel
generating a SIGILL to the process after being unable to push a new
signal context.

It uses lvm(8) facilities to install a DragonFly system in a
logical volume made of as many disk as you specify in the disk
list. It creates a swap partition and a /boot UFS filesystem
as it is required for proper operation.

- Use ether_ifattach() instead of if_attach() to attach carp and carp's
ioctl methed will fallback to ether_ioctl().
- VHID changes will be reflected into the carp's ethernet address.
- Reimplement carp output path.
* carp uses the parent's if_output() i.e. ether_output(), but passes
the carp interface's ifp.
* The ether_output() is adjusted to detect the carp interface and
switch to the carp's parent interface just before performing the
real output.
* ARP resolve will use carp instead of its parent interface, thus
the ARP output's source ethernet address and the sender hardware
address are consistent and loopback on the carp will work as
expected.
- Reimplement carp input path>
* Input interface will be changed to carp if the packet is destined
to the carp's ethernet address.
* If the received packet is broadcast or multicast, all of the carps
on the receiving interface will receive a copy of the packet.
- Fix up gratuitous ARP.
* No gratuitous ARP will be sent for carp upon IP address changes.
* Gratuitous ARP sent by carp use itself as interface not carp's
parent interface.
- Fix up ARP input path. Since ARP request is broadcast packet, parent
interface of the carp will also receive the packet and will reply the
ARP request. If carp and its parent interface have same IP address,
the parent's ARP reply will confuse the ARP requester: the ethernet
address of the IP is no longer carp's ethernet address.
- Rework carp's prefix route addition and deletion.
* Add IP addresses to carp will not add prefix routes
* Bring carp interface up will not add prefix routes for carp's
existing IP addresses
* Carp IP addresses prefix route will be added when carp is master,
and the parent's corresponding IP addresses prefix route will be
deleted.
* Carp IP addresses prefix route will be deleted when carp is no
longer master and the parent's corresponding IP addresses prefix
route will be added back.
- Handle carp parent interface's up/down events.
* When carp's parent is down, we fake up a parent IP address deletion
event for carp.
* When carp's parent is up, we fake up a parent IP address addition
event for carp.
- Stringent checks on CARP proto input path.
- Nullfy ifnet's serialier; carp is protected by global carp token.
- Mark CARP protocol MPSAFE

* PG_NEED_COMMIT pages are unwired from the buffer cache they are now
unconditionally placed on the active queue, even if 'activate' is not
set.

* This results in non-freeable tmpfs pages remaining in the active queue
most of the time. They will be cycled into the inactive queue and flushed
out if swap is present as per normal pageout daemon operation,

When swap is not present or is full, these pages are reactivated
unconditionally.

The various toolchains we build during buildworld need different
search paths for various stages. The ${USRDATA_PREFIX} variable,
which has different values depending on the stage, is used as a
prefix so that the compilers we use to build our world can search
their includes and libraries in /usr/obj. For the compiler that
ultimately gets installed upon installworld, the prefix is empty.

In ld's Makefile, the correct path prefixed with ${USRDATA_PREFIX}
is already added to the default path a few lines above, so all is
good. This commit removes the extra /usr/lib that was unconditionally
added after the prefixed one (which is wrong).

For all arches except sparc, gcc emits the section directive for the
following struct with a PROGBITS type. However, newer versions of binutils
(after 2.16.90) require the section to be of NOTE type, to guarantee that
the .note.ABI-tag section correctly ends up in the first page of the final
executable.

Unfortunately, there is no clean way to tell gcc to use another section
type, so this C file (or the C file that includes it) must be compiled in
multiple steps:

- Compile the .c file to a .s file.
- Edit the .s file to change the 'progbits' type to 'note', for the section
directive that defines the .note.ABI-tag section.
- Compile the .s file to an object file.

These steps are done in the invididual Makefiles for each applicable arch.

Taken-from: FreeBSD SVN 217375 (13 JAN 2011)

On i386 crtn.S:
Keep the stack aligned to a 16 byte boundary when calling init functions
so that we don't cause a bus error if they start storing SSE math stuff
on the stack.

Add support for STT_GNU_IFUNC and R_MACHINE_IRELATIVE GNU extensions to
rtld. This adds runtime bits neccessary for the use of the dispatch
functions from the dynamically-linked executables and shared libraries.

To allow use of external references from the dispatch function, resolution
of the R_MACHINE_IRESOLVE relocations in PLT is postponed until GOT entries
for PLT are prepared, and normal resolution of the GOT entries is finished.
Similar to how it is done by GNU, IRELATIVE relocations are resolved in
advance, instead of normal lazy handling for PLT.

get_program_var_addr() must prefer the strong symbol to the weak one.
Search global objects, together with main object and dependencies for the
requested symbol.

Move the common code from symlook_default() into new helper
symlook_global(), and use it both in symlook_global() and
get_program_var_addr(). Supply lock state to get_program_var_addr().

Taken-from: FreeBSD SVN 217223 (10 JAN 2011)

Eliminate the use of symlook_needed function in favor of DAGS. Place
elements on DAG lists in breadth-first order. This allows us to walk
pre-built list in all cases where breadth-first dependency chain
enumeration is required.

Fix dlsym on special handle obtained by dlopen(NULL, ...) to do what
comment claims it does. Take advantage of recently added symlook_global
function to iterate over main objects and global DAGs lists properly in
search of a symbol. Since rtld itself provides part of the global
namespace, search rtld_obj too.

Remove recursion from init_dag and symlook_needed functions. Use
symlook_needed for ELF filtee processing only and change lookup order
used in the function to match the order used by Solaris runtime linker
under same circumstances. While there, fix weak symbol handling in the
loop so that we return the first weak symbol definition if no strong one
was found, instead of the last one.

This functionality requires kernel support to determine the initial stack
access mode. This is how it's supposed to work:

If the loaded DSO requires an executable stack as specified by the PF_X
bit or p_flags on PT_GNU_STACK phdr, yet the current stack protection does
not permit execution: The map_stacks_exec function should change the
stack protection mode of all thread stacks.

The PT_GNU_STACK phdr parser has been implemented as well as a private
interface to _rtld_get_stack_prot() in order to export the stack access
mode calculated by rtld.

Left to do:
1) Implement stack protection in the kernel
2) Add PT_GNU_STACK functionality in the kernel
3) Add a method to change stack protection mode in libc or libthread
4) Implement map_stacks_exec function in rtld.

Filtrees are loaded on demand unless LD_LOADFLTR environment variable is
set or -z loadfltr was specified during the linking. This forces rtld
to upgrade read-locked rtld_bind_lock to write lock when it encounters an
object with filter during symbol lookup.

Consolidate common arguments of the symbol lookup functions in the SymLook
structure.

The ability to build an executable dynamic linker was previously removed
from the main makefile, so uncommenting LDSCRIPT in the arch Makefile
would no longer work even if the elf_rtld.x files were put in the arch
directory. To avoid confusion, these optional Makefiles have been
completely removed.

The dynamic linker is linked with the specially built static pic libc to
get some C runtime services such as printf(). Unfortunately, the
multithread-safeness measures in libc do now work in the rtld environment.

The dynlinker now uses FreeBSD's kernel printf() implementation instead of
libc's version. This printf does not require any shared global data and
thus is mt-safe. This commit replaces printf() and related functions with
rtld_ versions, and also removes calls to err(3).

Currently stdio is still pulled from libc within the libmap implementation
that uses fopen(). This is safe, yet not optimal, and is a candidate for
future change.

The makefile was cleaned up to remove the unused bits to building an
executable dynlinker and also require gnu99.

__getosreldate isn't used by rtld currently. The FreeBSD dynamic linker
does use it indirectly in libc's mmap wrapper. The capability is included
here both to ease the task to synchronizing with FreeBSD, and to quickly
obtain the capability in the future if necessary. It's currently disabled
with the undefined ENABLE_OSRELDATE macro.

The splitting of digest_dynamic required to use aux vectors also has the
benefit of avoiding the use of malloc at startup.

The FreeBSD repository is still handled by CVS, but its converted to
Subversion and from that, git. Neither the svn nor git version feature
expanded $FreeBSD$ tags. The only way to get this is to pull directly
from CVS which isn't convenient.

In the case of a few files, the only difference between the DragonFly
version and the FreeBSD version is the CVS tag. As the main development
of rtld is happening on FreeBSD and since I've started collaborating
with FreeBSD developers on new dynamic linker features, we want to
actively keep our linkers synchronized. Compressing the FreeBSD CVSID
tags makes that easier for me, the only person currently maintaining
the dynamic linker. The usually-wrong expanded CVS tag wasn't providing
any useful information to me either.