Set the GLIBC default version to 2.9.
This prevents deprecated functions from being included in libc,
and also ensures that version numbers match between X86-32 and
X86-64 (for PNaCl compatibility).

R=sehr@google.com,eaeltsin@chromium.org,mcgrathr@google.com
BUG= http://code.google.com/p/nativeclient/issues/detail?id=1819
TEST=

Review URL: http://codereview.chromium.org/7108039
Revert "Set the GLIBC default version to 2.9."

This reverts commit 5c44c72879f8d0b4ed421f66ed01af30addf3678.
It breaks the glibc build and nobody has yet investigated how or why.

BUG=none
TEST=none

R=eaeltsin@google.com,pdox@google.com

Review URL: http://codereview.chromium.org/7292001
Adjust for new NaCl startup ABI

This replaces the startup code for applications (crt1.o) and the dynamic
linker startup and glue code with versions adapted to the new NaCl startup
ABI.  This uses the normal C function-call ABI to start the e_entry address
as a function of one argument, that being an information block holding the
arguments, environment, etc.

This is to enable http://codereview.chromium.org/7276050/, which see.

BUG=http://code.google.com/p/nativeclient/issues/detail?id=1131
TEST=manually tested, bots can't test because of staging issues

R=pasko@google.com,eaeltsin@google.com,mseaborn@google.com

Review URL: http://codereview.chromium.org/7282019
Skip IMC argument fetching for any kind of imc_accept failure

No matter why imc_accept fails, if it does, we're not going to succeed in
doing the arguments-by-IPC dance.  In practice, the failure mode when there
is an IRT but no plugin is EINVAL (should probably be ENOTSOCK).

BUG=none
TEST=makes it possible for nacl scons blob_loading_library test to work

R=eaeltsin@google.com,khim@google.com,pasko@google.com

Review URL: http://codereview.chromium.org/7301017
Support IRT. Use syscalls fallback if IRT is not available.

R=pasko@google.com

Review URL: http://codereview.chromium.org/7084002
Fix up glibc for drift in syscall and IRT interfaces

The glibc copy of the IRT interfaces is out of date.  Fix it up.  The glibc
copy of the pre-IRT syscall interfaces was also out of date (passing extra
arguments since removed), and with http://codereview.chromium.org/7593001/
that mismatch comes to matter.  Fix that up too.

BUG= cleanup
TEST= hand built glibc and ran nacl tests against it

R=khim@google.com,pasko@google.com

Review URL: http://codereview.chromium.org/7569023
Fix __brk function (vital for static linking).

BUG=http://code.google.com/p/nativeclient/issues/detail?id=2112
TEST=glibc_tests

R=pasko@google.com

Review URL: http://codereview.chromium.org/7602013
[noupstream] Use unique filename: NACL_FAKE_SONAME.

This is temporary measure till we'll have stable ABI in NaCl GLibC.

BUG=http://code.google.com/p/nativeclient/issues/detail?id=2128

R=pasko@google.com

Review URL: http://codereview.chromium.org/7621016
Remove temporary DSO hack. Use open-resource call.

Still hacky, but works. Commited TBR to unblock the team.

Please comment anyway since there will be follow up patch
to cleanup stuff.

Review URL: http://codereview.chromium.org/7648050
Remove useless __nacl_irt_ppapi_* functions.

Also add "lost" Versions to fix the build.

Commited TBR to fix buildbots.

R=eaeltsin@google.com

Review URL: http://codereview.chromium.org/7621049
[noupstream] Correctly handle sonames with "a-f" hex numbes.

Commited TBR to fix the bots.

R=eaeltsin@google.com

Review URL: http://codereview.chromium.org/7677009
Align TLS segment to 64 bytes

Atom pays a hefty penalty for segment bases that are not cache-aligned.
Cache lines are 64 bytes on these machines.

BUG= http://code.google.com/p/nativeclient/issues/detail?id=1905
TEST= none

R=pasko@google.com

Review URL: http://codereview.chromium.org/7542019
Access only %gs:0, not other offsets from %gs

We want to deprecate any segment register access other than %gs:0.

BUG= http://code.google.com/p/nativeclient/issues/detail?id=2176
TEST= ran small_tests (including thread tests) with hand-built glibc

R=eaeltsin@google.com,pasko@google.com,khim@google.com

Review URL: http://codereview.chromium.org/7706022
Fix dynamic library linking.

Align the BSS to a 64k page boundary in order to work around the issue
NaCl's mmap() has with zero filling.

More discussion can be found here:
  http://code.google.com/p/nativeclient/issues/detail?id=1068

BUG=http://code.google.com/p/nativeclient/issues/detail?id=2184
TEST=see bug #2184

R=pasko@google.com

Review URL: http://codereview.chromium.org/7715030
Remove nonzero %gs access from bits/atomic.h

We want to deprecate any segment register access other than %gs:0.
These cases were missed in the last change.

BUG= http://code.google.com/p/nativeclient/issues/detail?id=2176
TEST= hand-examined output code for %gs use and correct lock insn sequences

R=eaeltsin@google.com,pasko@google.com,khim@google.com

Review URL: http://codereview.chromium.org/7718012
Allow static linking with PIC libraries using TLS

Added __tls_get_addr symbol to the static libc.a library.

Static linker scripts:
  * move .text section to lowest addresses
  * add .rela.got section to the readonly segment, it is needed when input
    object files use General Dynamic TLS model
  * move .plt in front of .text as it is done in non-static case
    (should use dlopen() with static linking to test that, not done)
  * adjust seg_rodata to start from .note.gnu.build-id
  * removed the .interp section, will it ever be non-empty for static
    executables?

The problem of .text section not being the first is that other sections, if
non-empty, add another noexec segment in front, which makes the load address of
the code segment different from 0x20000, i.e. not loadable by sel_ldr.

In dynamic linking script .text goes first as well which would make it easier to
merge the two scripts later.

BUG=http://code.google.com/p/nativeclient/issues/detail?id=1631
TEST=x86_64-nacl-g++ empty-main.c -static -T ldscripts/elf64_nacl.x.static

Review URL: http://codereview.chromium.org/7715035
Don't use open_resource as regular file access.

Use open_resource only for DSOs.  Don't use regular open for DSOs
if open_resource is available (can be changed by program later if
needed).

R=eaeltsin@google.com

Review URL: http://codereview.chromium.org/7776004
Change the size of runtime tls_index to match GOT reality.

BUG=http://code.google.com/p/nativeclient/issues/detail?id=2200
TEST=See http://code.google.com/p/nativeclient/issues/detail?id=2199

Review URL: http://codereview.chromium.org/7782008
Change soname of ld.so to say nacl rather than linux, use .1 in PT_INTERP name

NaCl is not Linux, don't use that name in a SONAME.
The rtld-installed-name is what's used in PT_INTERP for locally-built
binaries.  We don't want the NACL_FAKE_SONAME munging in there, just
a permanent name we can use for enabling NaCl-on-Linux hacks.

BUG= none
TEST= toolchain trybot

R=pasko@google.com,eaeltsin@google.com

Review URL: http://codereview.chromium.org/7785014
Change dynamic-linking linker scripts to produce a PT_INTERP

This is necessary for the -dynamic-linker option to the linker
(passed by the compiler driver for dynamic linking) to have any
useful effect.

BUG= none
TEST= hand-tested that links get a PT_INTERP

R=pasko@google.com,eaeltsin@google.com

Review URL: http://codereview.chromium.org/7785031