Victor Khimenko [Thu, 25 Apr 2013 17:18:58 +0000 (21:18 +0400)]
[NOUPSTREAM] Make non-executable stack default for NaCl.
It makes no sense to try to support executable stacks in NaCl.
Disable them at GLibC level.
In the new toolchain we probably don't want to do that and want to change default_execstack instead.
BUG=https://code.google.com/p/nativeclient/issues/detail?id=3402
TEST= run cordy with patch applied on top of Chrome 28.0.1486.1
R=halyavin@google.com
Review URL: https://codereview.chromium.org/
14494008
Andrey Khalyavin [Thu, 25 Apr 2013 15:24:55 +0000 (19:24 +0400)]
Fill tz in gettimeofday function.
Manual says that this obsolete field should be filled but we ignore it.
Fill it with zero values instead to increase compatibility.
BUG= NONE
TEST= NONE
R=khim@chromium.org
Review URL: https://codereview.chromium.org/
14373015
Ken Mixter [Tue, 23 Apr 2013 18:51:40 +0000 (11:51 -0700)]
Prepare for fast loading through mmap'ing text.
This changes the dynamic text mapping code to attempt PROT_EXEC mapping the text and only if it fails, falling back to read-mapping and using dyncode create.
TEST=newly generated libraries loaded by unmodified sel_ldr.
dyncode create path is used, code validates, runs fine.
TEST=newly generated libraries loaded by a modified sel_ldr
that allows PROT_EXEC mmaping if mmap starts and ends
on a page align. libraries load.
BUG=https://code.google.com/p/nativeclient/issues/detail?id=3371
Review URL: https://codereview.chromium.org/
13598032
Roland McGrath [Thu, 11 Apr 2013 18:47:56 +0000 (11:47 -0700)]
Linker scripts: Fold .fini into .text
In the previous iteration, a link with no .fini sections in any
of its input files would foul up the page alignment and padding.
The output section must be one with some code sections among its
input sections to ensure that the padding emitted in the output
section is nop instructions rather than zero bytes.
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3371
TEST= toolchain trybot and inspection of binaries
R=mseaborn@chromium.org
Review URL: https://codereview.chromium.org/
13954009
Roland McGrath [Fri, 5 Apr 2013 20:11:57 +0000 (13:11 -0700)]
Align and pad code segments to 64k
Fiddle the linker scripts to ensure that the code segment starts and ends
on a 64k boundary and the end is padded with valid instructions (nop).
This is necessary to permit direct mapping of code segments from files.
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3371
TEST= toolchain trybot and inspection of binaries
R=mseaborn@chromium.org
Review URL: https://codereview.chromium.org/
13638011
Petr Hosek [Thu, 4 Apr 2013 15:04:08 +0000 (08:04 -0700)]
Provide mprotect syscall
Expose the mprotect syscall which is a part of experimental IRT interface.
BUG= http://code.google.com/p/nativeclient/issues/detail?id=895
TEST= glibc trybots
Review URL: https://codereview.chromium.org/
12382030
Roland McGrath [Fri, 22 Feb 2013 00:07:54 +0000 (16:07 -0800)]
Disable ld.so.cache support
The ld.so.cache file never exists in a NaCl manifest and there
is no benefit to using such a file in the NaCl context. When
using sel_ldr -a or the environment variable equivalent on a
Linux host, searching for this file can hit the native host
file and have unintended effects on library search.
BUG= http://code.google.com/p/nativeclient/issues/detail?id=3316
TEST= toolchain trybot
R=bradnelson@google.com
Review URL: https://codereview.chromium.org/
12340013
Andrey Khalyavin [Mon, 21 Jan 2013 15:33:51 +0000 (19:33 +0400)]
Remove alignment of code and data segments for shared libraries.
Unlike ld.so code and data segments in shared libraries do not need
to be aligned to page boundary. So I remove the alignment from
linker scripts but return it back in elf/Makefile for ld.so.
Also fix ld.so to allocate ELF header in the heap if code segment
is not aligned to page boundary.
BUG= https://code.google.com/p/nativeclient/issues/detail?id=1794
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3266
TEST= toolchain glibc try bots.
Review URL: https://codereview.chromium.org/
11958039
Andrey Khalyavin [Thu, 17 Jan 2013 08:02:34 +0000 (12:02 +0400)]
Remove alignment between read-only and read-write data segments.
Executables loaded by sel_ldr are not required to have read-write data segment
aligned to page boundary. Libraries loaded by ld.so do not need it either.
BUG= http://code.google.com/p/nativeclient/issues/detail?id=1794
TEST= glibc toolchain trybots
Review URL: https://codereview.chromium.org/
11875034
Andrey Khalyavin [Mon, 14 Jan 2013 14:41:42 +0000 (18:41 +0400)]
Remove unnecessary alignment between .got.plt and .data sections.
The end of .got.plt and start of the .data section must be located
in read-write segment. So we don't need any alignment between them.
BUG= http://code.google.com/p/nativeclient/issues/detail?id=1794
Review URL: https://codereview.chromium.org/
11888007
Andrey Khalyavin [Mon, 1 Oct 2012 10:55:37 +0000 (14:55 +0400)]
Remove aliases to stat64, fstat64, fstatat64 and lstat64.
This aliases were enabled if inline functions were not used because of low optimization level.
BUG= none
TEST= none
R=khim@google.com,eaeltsin@google.com
Review URL: https://codereview.chromium.org/
10986081
Roland McGrath [Mon, 2 Jul 2012 21:28:24 +0000 (14:28 -0700)]
Fix bswap_64 for x86-64
Use the correct type name for the 64-bit integer type.
BUG= http://code.google.com/p/chromium/issues/detail?id=133889
TEST= locally tested it fixes run_byteswap64_test
R=bradchen@google.com
Review URL: https://chromiumcodereview.appspot.com/
10702071
David Sehr [Thu, 31 May 2012 22:54:40 +0000 (15:54 -0700)]
Correct building runnable-ld.so to ensure that the stack on entry to main is
aligned for 0mod16 on x86-32.
BUG= http://code.google.com/p/nativeclient/issues/detail?id=2665
TEST=run_call_structs_test
run_nameservice_test
run_pagesize_test
run_thread_test
run_float2_test
run_types_srpc_test_nexe
run_simple_srpc_test_nexe
Review URL: https://chromiumcodereview.appspot.com/
10443117
Victor Khimenko [Wed, 23 May 2012 17:16:37 +0000 (21:16 +0400)]
Fix pthread_cond_timedwait (and other similar functions)
Fix absolute/relative times mixup in pthread_cond_timedwait (and
other timed wait functions).
Simple solution will be to fix it in futex_emulation.c, but this
will lead to two additional calls to gettimeofday in very timing-critical
parts of the code.
Instead we remove these calls in the cases where GLibC-provided interface
received absolute timeout and only keep them in cases where POSIX-mandated
API uses relative timeouts.
Change structured in a way to trigger error as early as possible (usually
in compilation time, if a few cases in linking time).
BUG=http://code.google.com/p/nativeclient/issues/detail?id=2804
TEST=cond_timedwait (see https://chromiumcodereview.appspot.com/
10414059/)
Review URL: https://chromiumcodereview.appspot.com/
10421027
Victor Khimenko [Wed, 16 May 2012 10:19:35 +0000 (14:19 +0400)]
Turn waiting stack back into wating queue
When hand-made list was changed to use glibc-offered primitives
it accidently turned wating list to waiting stack. Formally this
is still POSIX-compatible interface, but many real programs don't
like it.
This is "good" version:
http://codereview.chromium.org/3384028/#ps36030
This is "bad" one:
http://codereview.chromium.org/3384028/#ps42001
R=halyavin@google.com
Review URL: https://chromiumcodereview.appspot.com/
10391160
Egor Pasko [Fri, 11 May 2012 12:31:30 +0000 (16:31 +0400)]
add clock() in nacl-glibc
BUG=none
TEST=none
Review URL: https://chromiumcodereview.appspot.com/
10381109
Stanislav Vorobyev [Thu, 26 Apr 2012 13:16:28 +0000 (17:16 +0400)]
fix 32-bit socket() interceptor
BUG=
TEST=
Review URL: https://chromiumcodereview.appspot.com/
10235002
Stanislav Vorobyev [Mon, 23 Apr 2012 08:00:19 +0000 (12:00 +0400)]
berkeley sockets interception implementation
Adds hooks for all the socket-related functions. By default hooks return ENOSYS, but can be intercepted in the application.
Return these:
e98ec8c fixed signatures for several syscalls that return positive value in correct case
256e1ec removed epoll_create1 (EPOLL_CLOEXEC is not applicable to NaCl, as there is no possibility to fork); added recv and send to syscalls.list
0533bbb added several system call hooks for future sockets implementation
BUG=
TEST=trybot
Review URL: https://chromiumcodereview.appspot.com/
10134022
Egor Pasko [Thu, 19 Apr 2012 19:47:04 +0000 (23:47 +0400)]
revert 4 untested commits
Revert these:
e98ec8c fixed signatures for several syscalls that return positive value in
correct case
256e1ec removed epoll_create1 (EPOLL_CLOEXEC is not applicable to NaCl, as there
is no possibility to fork); added recv and send to syscalls.list
0533bbb added several system call hooks for future sockets implementation
BUG=broken REVISIONS roll
TEST=cd native_client/tools && make glibc-check
Review URL: https://chromiumcodereview.appspot.com/
10070014
Robert Muth [Wed, 18 Apr 2012 23:26:22 +0000 (16:26 -0700)]
Make it possible to run the loader with LD_DEBUG=all
This currently asserts because getpid() returns -1
BUG=none
TEST=manual
R=mcgrathr@chromium.org
Review URL: https://chromiumcodereview.appspot.com/
10021073
Stanislav Vorobyev [Wed, 18 Apr 2012 12:40:59 +0000 (16:40 +0400)]
fixed signatures for several syscalls that return positive value in correct case
BUG=
TEST=
Review URL: https://chromiumcodereview.appspot.com/
10095013
Stanislav Vorobyev [Mon, 16 Apr 2012 11:33:40 +0000 (15:33 +0400)]
removed epoll_create1 (EPOLL_CLOEXEC is not applicable to NaCl, as there is no possibility to fork); added recv and send to syscalls.list
BUG=
TEST=
Review URL: https://chromiumcodereview.appspot.com/
10095010
Brad Chen [Fri, 13 Apr 2012 17:01:06 +0000 (10:01 -0700)]
Patch NaCl glibc to avoid use of fsincos.
Additionally remove inline and 64-bit uses of fsincos.
Patch NaCl glibc to avoid use of fsincos.
BUG=http://code.google.com/p/nativeclient/issues/detail?id=2720
TEST=bots
Review URL: https://chromiumcodereview.appspot.com/
10066026
Stanislav Vorobyev [Fri, 13 Apr 2012 12:13:43 +0000 (16:13 +0400)]
added several system call hooks for future sockets implementation
FOA, select or poll would be implemented, of course.
Should I add __nacl_irt_... call hooks for common berkeley socket calls (accept, bind, listen, connect, send, recv, gethostby[name,addr], sendto, recvfrom, [set,get]sockopt)?
BUG=
TEST=
Review URL: https://chromiumcodereview.appspot.com/9969049
Stanislav Vorobyev [Fri, 30 Mar 2012 14:36:55 +0000 (18:36 +0400)]
added several syscalls for nacl mounts
BUG=
TEST=
Review URL: https://chromiumcodereview.appspot.com/9965011
Roland McGrath [Thu, 23 Feb 2012 00:50:59 +0000 (16:50 -0800)]
Implement sleep function using nanosleep
The Linux implementation we were getting fails because of missing
signal support (which is only used there for arcane reasons that
are now obsolete even on Linux). The trivial version calling
nanosleep works just fine.
BUG= http://code.google.com/p/nativeclient/issues/detail?id=2288
TEST= none
R=bradchen@google.com
Review URL: https://chromiumcodereview.appspot.com/9431051
Bennet Yee [Wed, 15 Feb 2012 22:48:08 +0000 (14:48 -0800)]
plumb glibc clock_get interfaces to irt
cargo-culted changes to add sysdeps/nacl/ files to librt's
clock_gettime/clock_getres implementation. seems to work.
R=mcgrathr@google.com
BUG= http://code.google.com/p/nativeclient/issues/detail?id=2477
TEST= in separate CL that cannot be submitted w/o TC DEPS roll
Review URL: https://chromiumcodereview.appspot.com/9389024
Roland McGrath [Wed, 14 Dec 2011 17:30:43 +0000 (09:30 -0800)]
Fix __jmp_buf size for x86-64
Because of the type used vs the ILP32 configuration, this type is too
small for the assembly code that uses it. It's hard to notice in
straightforward tests because the public jmp_buf type effectively has
unused padding (the space for the signal state). But the internal
type is used in the implementation of pthread_cleanup_push, such that
using that interface will clobber nearby stack. Note that the C++
implementation and the C implementation used under -fexceptions don't
use this.
BUG= http://code.google.com/p/nativeclient/issues/detail?id=2490
TEST= toolchain trybot
R=elijahtaylor@google.com,pasko@google.com,khim@google.com,eaeltsin@google.com
Review URL: http://codereview.chromium.org/8937018
Roland McGrath [Tue, 13 Dec 2011 22:01:47 +0000 (14:01 -0800)]
Fix x86-64 DT_PREINIT_ARRAY/DT_INIT_ARRAY/DT_FINI_ARRAY calls for ILP32 layout
We were skipping the odd-numbered elements of DT_PREINIT_ARRAY,
DT_INIT_ARRAY and DT_FINI_ARRAY because we were treating them as arrays
of 64-bit quantities but they actually hold 32-bit quantities.
BUG= http://code.google.com/p/nativeclient/issues/detail?id=2482
TEST= toolchain trybots
R=pdox@google.com,pasko@google.com,khim@google.com,eaeltsin@google.com
Review URL: http://codereview.chromium.org/8932007
Ivan Krasin [Fri, 18 Nov 2011 23:15:57 +0000 (15:15 -0800)]
Define __WORDSIZE 32 for strt* routines
BUG=http://code.google.com/p/nativeclient/issues/detail?id=2444
TEST=run_strtoll_test,run_strtoull_test
Review URL: http://codereview.chromium.org/8586057
Roland McGrath [Wed, 16 Nov 2011 18:40:50 +0000 (10:40 -0800)]
Use proper strto*ll implementation on x86-64
On normal x86-64, this is replaced with an alias for strto*l
because long==long long. On NaCl, that's not right.
BUG= http://code.google.com/p/nativeclient/issues/detail?id=2444
TEST= toolchain trybot
R=krasin@google.com,pasko@google.com,khim@google.com
Review URL: http://codereview.chromium.org/8578011
Victor Khimenko [Tue, 1 Nov 2011 13:45:04 +0000 (17:45 +0400)]
Fix recursive pthread_once.
Use more robust Linux-IA64 implementation instead of generic one.
BUG=http://code.google.com/p/nativeclient/issues/detail?id=2398
R=pasko@google.com
Review URL: http://codereview.chromium.org/8387030
Victor Khimenko [Wed, 19 Oct 2011 20:34:30 +0000 (00:34 +0400)]
Don't use Linux code in sysconf(_SC_NPROCESSORS_ONLN)
BUG=http://code.google.com/p/nativeclient/issues/detail?id=2202
TEST=earth (look for "Using 16 processors based on sysconf" message)
R=pasko@google.com
Review URL: http://codereview.chromium.org/8339017
Victor Khimenko [Tue, 18 Oct 2011 12:35:32 +0000 (16:35 +0400)]
Fix negative values handling.
Don't try to be too clever - trust the IRT results in sbrk.
BUG=http://code.google.com/p/nativeclient/issues/detail?id=2294
R=pasko@google.com
Review URL: http://codereview.chromium.org/8321010
Victor Khimenko [Wed, 5 Oct 2011 15:41:33 +0000 (19:41 +0400)]
Fix compilation with newer version of linux-headers.
Found as result of Gentoo porting efforts.
R=halyavin@google.com
Review URL: http://codereview.chromium.org/8143020
Evgeny Eltsin [Tue, 4 Oct 2011 23:54:44 +0000 (16:54 -0700)]
Introduce __nacl_add_tp
__nacl_add_tp returns thread pointer plus an offset passed in the first argument.
BUG=http://code.google.com/p/nativeclient/issues/detail?id=237
TEST=
Review URL: http://codereview.chromium.org/8143011
Andrey Khalyavin [Mon, 3 Oct 2011 17:30:54 +0000 (21:30 +0400)]
Fix error codes in read and sched_yield.
BUG= http://code.google.com/p/nativeclient/issues/detail?id=2329
TEST= none
R=khim@google.com
Review URL: http://codereview.chromium.org/8116004
Victor Khimenko [Tue, 27 Sep 2011 18:59:20 +0000 (22:59 +0400)]
Fix GLibC compilation.
We need to explictly add ld.so to the list of libraries because
otherwise nscd can not call syscalls. We don't really need or
support nscd in NaCl but it should be buildable.
R=pasko@google.com
Review URL: http://codereview.chromium.org/8050019
Victor Khimenko [Tue, 20 Sep 2011 13:31:23 +0000 (17:31 +0400)]
Use irt's open_resource only for files in /lib
When I've added "lib" prefix I was under impression that
open_resource should be used to open all kind of resources.
Such as:
/lib/libc.so.VERSION - it's a libc binary itself
/lib/gconv/gconv-modules - list of supported gconv modules
/share/locale/locale.alias - locale aliases
But this plan was vetoed on Chrome side. Now resource_open
is supposed to be used exclusively for DSO. It makes no sense
to use directories in such a case.
Now we use different scheme:
/lib/libpthread.so.VERSION is loaded using IRT's open_resource
/usr/lib/libpthread.so.VERSION is loaded using regular open(2)
R=pasko@google.com
Review URL: http://codereview.chromium.org/7937005
Andrey Khalyavin [Tue, 20 Sep 2011 11:47:46 +0000 (15:47 +0400)]
Fix bug with open64.
BUG= http://code.google.com/p/nativeclient/issues/detail?id=2256
TEST= none
Review URL: http://codereview.chromium.org/7970007
Roland McGrath [Mon, 12 Sep 2011 22:50:45 +0000 (15:50 -0700)]
Add nacl_interface_query public function
This adds a public function for doing the IRT interface query.
This matches the function being added to the newlib-based libnacl.
BUG=http://code.google.com/p/nativeclient/issues/detail?id=2246
TEST=none
R=khim@google.com,pasko@google.com,eaeltsin@google.com
Review URL: http://codereview.chromium.org/7844009
Victor Khimenko [Mon, 12 Sep 2011 12:31:48 +0000 (16:31 +0400)]
Remove obsolete 16bit uid/gid code from IA32 glibc.
Small step in IA32/x86-64 unification process: define
__ASSUME_32BITUIDS to remove all code related to 16bit uid/gid
syscalls.
Also define __ASSUME_LCHOWN_SYSCALL and __ASSUME_REALTIME_SIGNALS
to make code compileable. Later we'll probably want to define other
defines, but we'll need to carefully review them.
R=pasko@google.com
Review URL: http://codereview.chromium.org/7780002
Victor Khimenko [Tue, 6 Sep 2011 16:33:57 +0000 (20:33 +0400)]
Change make-syscalls.sh to make syscall interception possible.
This is second patch in series: it makes it possible to intercept
auto-generated syscalls. It uses "#define/#undef" trick to circumvent
type checking since syscalls.list contains only rough information
about types (int, char * or pointer to some struct - but WHICH
struct it's not known). Long-term solution it should probably be
replaced with a simple set of .c files - or may be just better
auto-generation mechanism.
R=pasko@google.com
Review URL: http://codereview.chromium.org/7737022
Victor Khimenko [Tue, 6 Sep 2011 12:25:03 +0000 (16:25 +0400)]
Fix getdents function.
Check for error was not inverted when conversion to IRT happened.
It was never noticed since we had no way to test this code in browser.
R=pasko@google.com
Review URL: http://codereview.chromium.org/7828098
Victor Khimenko [Sat, 3 Sep 2011 17:51:00 +0000 (21:51 +0400)]
Remove temporary IMC hack.
Browser support for this hack was removed about month ago and now
it's replaced with resources_open IRT interface... time for it to go.
R=pasko@google.com
Review URL: http://codereview.chromium.org/7739013
Victor Khimenko [Sat, 3 Sep 2011 12:30:59 +0000 (16:30 +0400)]
Replace #define syscalls cancel machinery.
Use inline functions for type-checking. Separate CL will allow
user to redefine/catch these functions.
R=pasko@google.com
Review URL: http://codereview.chromium.org/7785030
Victor Khimenko [Sat, 3 Sep 2011 10:46:23 +0000 (14:46 +0400)]
Don't use auto-initialized pointers to functions.
ld.so initializes these pointers after call to _dl_sysdep_start.
This means IRT is used to load libraries, but then we were using
straight NACL_SYSCALLs.
BUG=http://code.google.com/p/nativeclient/issues/detail?id=2219
R=pasko@google.com
Review URL: http://codereview.chromium.org/7792065
Victor Khimenko [Sat, 3 Sep 2011 09:17:41 +0000 (13:17 +0400)]
Quick and dirty fix to green the bots.
Replaces movdqa wath movups. Perhaps we can keep it as permanent solution:
1. Athlon XP (without SSE2!) is still around (under name Geode NX). One example:
http://www.netbookchoice.com/2010/06/10/asus-eee-pc-1201k-packs-an-amd-geode-processor/
2. Upstream comment in sysdeps/x86_64/dl-trampoline.S looks ominous enough:
/* Even though the stack is correctly aligned to allow using movaps
we use movups. Some callers might provide an incorrectly aligned
stack and we do not want to have it blow up here. */
movups %xmm0, 16(%rcx)
movups %xmm1, 32(%rcx)
This comment is removed (and code rewamped significantly) in upstream trunk,
but we'll need to redo porting work anyway: code is significantly different
there (because of the AVX support and other reasons).
Commited TBR to green the bots.
BUG= http://code.google.com/p/nativeclient/issues/detail?id=2208
TEST= look on buildbots
Review URL: http://codereview.chromium.org/7835015
Roland McGrath [Fri, 2 Sep 2011 18:01:45 +0000 (11:01 -0700)]
Fix alignment for SSE register saving
The movdqa instructions need the memory to be aligned to 16 bytes.
BUG= http://code.google.com/p/nativeclient/issues/detail?id=2208
TEST= none
R=pasko@google.com,khim@google.com,eaeltsin@google.com,mseaborn@chromium.org
Review URL: http://codereview.chromium.org/7828050
Roland McGrath [Thu, 1 Sep 2011 20:33:46 +0000 (13:33 -0700)]
Preserve SSE registers in PLT fixup
The dynamic linker's PLT fix-up path needs to preserve the x86-64 SSE
registers around calling complex code paths that can sometimes clobber
them. In upstream glibc after 2.10, these registers are saved and restored
in (almost) the same place.
BUG= http://code.google.com/p/nativeclient/issues/detail?id=2208
TEST= manual run of float_math.nexe under NACLVERBOSITY=4 fails with old runnable-ld.so, works with new runnable-ld.so
R=pasko@google.com,khim@google.com,eaeltsin@google.com
Review URL: http://codereview.chromium.org/7830016
Roland McGrath [Wed, 31 Aug 2011 17:58:11 +0000 (10:58 -0700)]
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
Roland McGrath [Wed, 31 Aug 2011 16:48:48 +0000 (09:48 -0700)]
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
Egor Pasko [Mon, 29 Aug 2011 14:57:45 +0000 (18:57 +0400)]
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
Victor Khimenko [Mon, 29 Aug 2011 14:01:14 +0000 (18:01 +0400)]
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
Egor Pasko [Fri, 26 Aug 2011 09:21:02 +0000 (13:21 +0400)]
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
Roland McGrath [Wed, 24 Aug 2011 18:08:22 +0000 (11:08 -0700)]
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
Victor Khimenko [Wed, 24 Aug 2011 17:56:58 +0000 (21:56 +0400)]
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
Roland McGrath [Tue, 23 Aug 2011 16:16:59 +0000 (09:16 -0700)]
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
Roland McGrath [Mon, 22 Aug 2011 20:35:09 +0000 (13:35 -0700)]
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
Victor Khimenko [Thu, 18 Aug 2011 07:52:57 +0000 (11:52 +0400)]
[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
Victor Khimenko [Wed, 17 Aug 2011 21:19:17 +0000 (01:19 +0400)]
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
Victor Khimenko [Wed, 17 Aug 2011 15:25:01 +0000 (19:25 +0400)]
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
Victor Khimenko [Mon, 15 Aug 2011 15:15:09 +0000 (19:15 +0400)]
[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
Victor Khimenko [Tue, 9 Aug 2011 10:57:46 +0000 (14:57 +0400)]
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
Roland McGrath [Mon, 8 Aug 2011 18:26:44 +0000 (11:26 -0700)]
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
Victor Khimenko [Thu, 28 Jul 2011 15:41:30 +0000 (19:41 +0400)]
Support IRT. Use syscalls fallback if IRT is not available.
R=pasko@google.com
Review URL: http://codereview.chromium.org/7084002
Roland McGrath [Mon, 11 Jul 2011 19:56:28 +0000 (12:56 -0700)]
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
Roland McGrath [Thu, 30 Jun 2011 17:15:06 +0000 (10:15 -0700)]
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
Roland McGrath [Thu, 30 Jun 2011 17:11:41 +0000 (10:11 -0700)]
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
David Meyer [Tue, 14 Jun 2011 23:43:48 +0000 (16:43 -0700)]
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
Egor Pasko [Mon, 6 Jun 2011 09:04:58 +0000 (13:04 +0400)]
Make alarm,fork,kill,pthread_kill return ENOSYS.
kill.c, fork.c:
Cannot be overridden via make_sysd_rules.py since they are generated from
syscalls.
register-atfork.c, unregister-atfork.c:
The C library invokes internal atfork handlers, add stubs to ignore this
activity.
tst-skeleton.c:
Skip linking with nosys stubs to avoid excluding tests based on the stub
warning.
BUG=http://code.google.com/p/nativeclient/issues/detail?id=1777
TEST=none
Review URL: http://codereview.chromium.org/7070003
Victor Khimenko [Mon, 30 May 2011 16:21:00 +0000 (20:21 +0400)]
Make GLibC IRT-compatible
Make it possible to run GLibC with IRT preloaded. IRT will not be used
but will it least run.
BUG=http://code.google.com/p/nativeclient/issues/detail?id=1874
TEST=scons-out/dbg-linux-x86-64/staging/sel_ldr -B ../scons-out/nacl-x86-64/staging/irt.nexe -S -a -s -- toolchain/linux_x86/nacl64/lib/runnable-ld.so
R=pasko@google.com,eaeltsin@google.com
Review URL: http://codereview.chromium.org/7085035
Andrey Khalyavin [Mon, 30 May 2011 07:05:50 +0000 (11:05 +0400)]
Remove non-validating functions that support gnu2 TLS dialect.
BUG= none
TEST= none
R=pasko@google.com
Review URL: http://codereview.chromium.org/7071041
Egor Pasko [Fri, 27 May 2011 10:31:23 +0000 (14:31 +0400)]
Make wait,waitpid,waitid nosys stubs.
The test skeleton is made not linked against waitpid to allow excluding other
tests based on a stub warning from waitpid linkage.
BUG=http://code.google.com/p/nativeclient/issues/detail?id=1777
TEST=none
Review URL: http://codereview.chromium.org/7079001
Andrey Khalyavin [Thu, 26 May 2011 06:56:07 +0000 (10:56 +0400)]
Remove colon from perror argument because perror outputs colon too.
BUG= none
TEST= none
R=pasko@google.com
Review URL: http://codereview.chromium.org/6976020
Andrey Khalyavin [Wed, 25 May 2011 12:35:01 +0000 (16:35 +0400)]
Small typo in _dl_runtime_profile.
BUG= none
TEST= none
R=khim@google.com
Review URL: http://codereview.chromium.org/7053012
Andrey Khalyavin [Wed, 25 May 2011 11:39:43 +0000 (15:39 +0400)]
Fix one bug and validation errors in dynamic linker profile path.
_dl_profile_fixup has last parameter "long int *framesizep". This
is 4 bytes in NaCl instead of 8 which are expected by assembler code
in _dl_runtime_profile.
BUG= http://code.google.com/p/nativeclient/issues/detail?id=876
TEST= run any nexe with sel_ldr option -E LD_PROFILE=some.nexe
R=khim@google.com
Review URL: http://codereview.chromium.org/6987008
Andrey Khalyavin [Wed, 25 May 2011 07:28:33 +0000 (11:28 +0400)]
Fix join with main thread bug.
We need to wake futex pthread_join is sleeping in. The code is the same as in the end of start_thread function in pthread_create.c.
BUG=http://code.google.com/p/nativeclient/issues/detail?id=1831
TEST=glibc tests
R=khim@google.com,pasko@google.com,mseaborn@chromium.org
Review URL: http://codereview.chromium.org/7066017
Andrey Khalyavin [Tue, 24 May 2011 06:42:42 +0000 (10:42 +0400)]
Remove obsolete System V context functions because __start_context doesn't validate in 64-bit.
R=pasko@google.com
BUG=http://code.google.com/p/nativeclient/issues/detail?id=876
TEST=compile glibc and run ./ncval --cpuid-all libc-2.9.so
Review URL: http://codereview.chromium.org/7037021
Andrey Khalyavin [Tue, 24 May 2011 06:41:21 +0000 (10:41 +0400)]
Ignore parameter of __exit_thread which is always zero anyway.
R=mseaborn@chromium.org
BUG=none
TEST=http://codereview.chromium.org/7039039/
Review URL: http://codereview.chromium.org/7004032
Evgeniy Stepanov [Fri, 20 May 2011 10:47:51 +0000 (14:47 +0400)]
Check that mmap-ed region size is positive before reporting it to Valgrind.
TEST=thread_test on the Valgrind/GLibC bot
R=pasko
BUG=
Review URL: http://codereview.chromium.org/7057003
Andrey Khalyavin [Thu, 19 May 2011 09:16:16 +0000 (13:16 +0400)]
Implement __exit_thread function in C in order to remove validator errors.
This function is called from csu/libc_start.c and should terminate the main thread
without terminating whole process. val is always 0 in the code.
BUG=http://code.google.com/p/nativeclient/issues/detail?id=876
TEST=http://codereview.chromium.org/7039039/
R=pasko@google.com,khim@google.com
Review URL: http://codereview.chromium.org/7034024
Egor Pasko [Tue, 17 May 2011 15:51:53 +0000 (19:51 +0400)]
Stub warning for pthread_cancel.
NaCl does not support pthread_cancel(). Add a stub warning that would be
produced at link time:
warning: pthread_cancel is not implemented and will always fail
BUG=http://code.google.com/p/nativeclient/issues/detail?id=1777
TEST=cat >pthr.c <<END
#include <pthread.h>
#include <stdio.h>
int main() {
pthread_t tid = pthread_self();
printf("pthread_cancel: %d\n", pthread_cancel(tid));
return 0;
}
END
/path/to/nacl64-gcc pthr.c -lpthread | \
grep "warning: warning: pthread_cancel is not implemented and will always fail"
Review URL: http://codereview.chromium.org/7031024
Evgeniy Stepanov [Mon, 16 May 2011 14:28:23 +0000 (18:28 +0400)]
Report data mappings to Valgrind.
Untrusted mmap() looks like a series of small mmaps() from the outside. This
confuses Valgrind. This change adds a hook that tells Valgrind to emulate a
correct, full size mmap() _before_ the real one(s).
R=pasko
BUG=http://code.google.com/p/nativeclient/issues/detail?id=1404
TEST=none
Review URL: http://codereview.chromium.org/7031004
Egor Pasko [Mon, 16 May 2011 11:50:27 +0000 (15:50 +0400)]
Return ENOSYS from sigaction(2).
signal/sigaction.c: provide __libc_sigaction
(it is wrapped in nptl, used during thread startup, etc.)
With this we perform less work in __libc_sigaction() invocation and provide a
stub warning that will be used to filter out the tests that we expect to fail
for a reason.
BUG=http://code.google.com/p/nativeclient/issues/detail?id=1777
TEST=none
Review URL: http://codereview.chromium.org/7015045
Egor Pasko [Tue, 10 May 2011 09:11:04 +0000 (13:11 +0400)]
Report new dynamic code mappings to Valgrind.
Normally Valgrind tracks dynamic library load by observing mmap() calls, but
that's not an option with NaCl.
The change is prepared by Evgeniy Stepanov, original review is at:
http://codereview.chromium.org/6927079
BUG=http://code.google.com/p/nativeclient/issues/detail?id=1404
TEST=none
Review URL: http://codereview.chromium.org/6980017
Roland McGrath [Wed, 4 May 2011 22:14:42 +0000 (15:14 -0700)]
Add pthread_setschedprio implemented with NaCl thread_nice
This implements the POSIX pthread_setschedprio call for the calling
thread only, using the NaCl thread_nice syscall. This matches the
nacl libpthread implementation.
BUG=none
TEST=none
R=pasko@google.com,khim@google.com,eaeltsin@google.com
Review URL: http://codereview.chromium.org/6901156
Roland McGrath [Wed, 4 May 2011 20:18:21 +0000 (13:18 -0700)]
Update codereview.settings for gerrit hosting
Fiddle the magic codereview.settings file for the new git hosting locations.
BUG=infrastructure
TEST=git cl upload working for this change!
R=khim@google.com,mseaborn@chromium.org,pasko@google.com,eaeltsin@google.com
Review URL: http://codereview.chromium.org/6927017
Roland McGrath [Tue, 3 May 2011 17:12:41 +0000 (10:12 -0700)]
Conditionalize static linker scripts for .rodata placement
Change the linker scripts for static linking so that if the symbol
__nacl_rodata_start is defined, that sets the address at which the
.rodata section starts. This lets a one-line linker script be
included in the link to specify the fixed placement needed to work
with a blob library.
BUG=none
TEST=none
R=pasko@google.com,khim@google.com,eaeltsin@google.com
Review URL: http://codereview.chromium.org/6903177
Egor Pasko [Fri, 29 Apr 2011 10:28:22 +0000 (14:28 +0400)]
Redirect to debug/st{p,r}cpy_chk.c
The change is prepared by Ivan Krasin. Original review is at:
http://codereview.chromium.org/6905021
BUG=http://code.google.com/p/nativeclient/issues/detail?id=876
TEST=nacl64 ncval_annotate.py out/install/glibc_64/nacl64/lib/libc.so.6
TBR=krasin
Egor Pasko [Fri, 29 Apr 2011 10:27:03 +0000 (14:27 +0400)]
Redirect to sysdeps/unix/sysv/linux/sched_getcpu.c to fix validation failures.
The change prepared by Ivan Krasin, original review is at:
http://codereview.chromium.org/6902056
BUG=http://code.google.com/p/nativeclient/issues/detail?id=876
TEST=nacl64 ncval_annotate.py out/install/glibc_64/nacl64/lib/libc.so.6
TBR=krasin
Roland McGrath [Wed, 27 Apr 2011 18:21:28 +0000 (11:21 -0700)]
Truncate x86-64 rtld's l_addr to 32 bits.
The vanilla ld.so code computes its own load address from the PC.
On x86-64 the whole PC value includes the %r15 base, which should
not be considered part of the address in NaCl.
Before this change, the l_addr of the dynamic linker itself is a large
value that does not fit into 32 bits. This leads to "causes overflow in
R_X86_64_32 relocation" warnings when the dynamic linker does the
relocation of its own data segment, which contains 32-bit pointer fields.
BUG=http://code.google.com/p/nativeclient/issues/detail?id=1411
TEST=rtld warning messages disappear in hand runs
R=khim@google.com,pasko@google.com,eaeltsin@google.com
Review URL: http://codereview.chromium.org/6883188
Egor Pasko [Mon, 25 Apr 2011 15:03:43 +0000 (19:03 +0400)]
Glibc side changes for running tests.
test-skeleton.c:
Disable test forking by default, workaround unimplemented getrlimit/setrlimit.
catgets/test-gencat.sh, malloc/mtrace.pl, nptl/tst-tls6.sh:
Skip the tests by modifying them, it is non-trivial to exclude them using the
make-based glibc test-suite.
BUG=http://code.google.com/p/nativeclient/issues/detail?id=1728
TEST=none
Review URL: http://codereview.chromium.org/6880173
Evgeny Eltsin [Thu, 21 Apr 2011 15:08:30 +0000 (19:08 +0400)]
Add sysrooted SEARCH_DIR commands to linker scripts
Now we have binutils configured with sysroot, and thus linker can correctly use SEARCH_DIR("=<path-relative-to-sysroot>") when searching for runtime libraries and other stuff.
The effect can be easily seen as follows:
Compile something with "nacl-gcc -nodefaultlibs -lm -Wl,-v t.c" (no default libraries, explicitly use libm, make ld a bit verbose).
libm has DT_NEEDED for libc, and ld will try to search for it.
Before this change it will be unable to find it:
...ld: warning: libc.so.6, needed by ...libm.so, not found (try using -rpath or -rpath-link)
After this change the warning should disappear
R=khim@chromium.org,mcgrathr@chromium.org
BUG=
TEST=see above
Review URL: http://codereview.chromium.org/6877123
Evgeny Eltsin [Thu, 14 Apr 2011 18:45:14 +0000 (22:45 +0400)]
Fix validation failures in _mcount.S
The change is from krasin@, original review URL:http://codereview.chromium.org/6820008/
BUG=http://code.google.com/p/nativeclient/issues/detail?id=876
TEST=nacl64 ncval_annotate.py out/install/glibc_64/nacl64/lib/libc.so.6
Review URL: http://codereview.chromium.org/6850017
Victor Khimenko [Tue, 12 Apr 2011 13:55:23 +0000 (17:55 +0400)]
Fix handling of spurious wakeups.
cond_wait/cond_timed_wait_abs can be waken up spurously without
help of our cond_signal. In this case we left thread in a waiters
list so next futex_wait corrupted the list.
R=eugenis@google.com
BUG=http://code.google.com/p/nativeclient/issues/detail?id=1638
TEST=Try to run NPTL torture tests
Review URL: http://codereview.chromium.org/6823039
Victor Khimenko [Mon, 11 Apr 2011 12:31:39 +0000 (16:31 +0400)]
Fix __nacl_futex_wake_op
All operations should be done with addr2, only unconditional
wakeup should be done with addr1.
R=dvyukov@google.com
BUG=http://code.google.com/p/nativeclient/issues/detail?id=1639
TEST=Try to run NPTL torture tests
Review URL: http://codereview.chromium.org/6821046
Andrey Khalyavin [Mon, 4 Apr 2011 12:39:36 +0000 (16:39 +0400)]
Add memcpy_chk.c to redirect list because 64-bit memcpy_chk.S relies on redirected memcpy.S.
BUG=http://code.google.com/p/nativeclient/issues/detail?id=1579
TEST=compile & check libc.so export for __memcpy_chk function.
Review URL: http://codereview.chromium.org/6693063
Mark Seaborn [Fri, 1 Apr 2011 17:29:15 +0000 (10:29 -0700)]
Fix validation errors in pthread_spin_* functions
Add generic portable implementations which are based on:
nptl/sysdeps/ia64/pthread_spin_lock.c (with "hint @pause" removed)
nptl/sysdeps/ia64/pthread_spin_trylock.c (identical)
Note that these generic implementations use 0=unlocked and 1=locked,
whereas the implementation in nptl/sysdeps/i386 uses the opposite
convention.
These are the last validation errors remaining in x86-32. There are
some others remaining in x86-64.
BUG=http://code.google.com/p/nativeclient/issues/detail?id=876
TEST=to be posted separately
Review URL: http://codereview.chromium.org/6708097
Andrey Khalyavin [Tue, 29 Mar 2011 13:21:25 +0000 (17:21 +0400)]
Remove _LARGEFILE64_SOURCE macro for Native Client.
BUG=http://code.google.com/p/nativeclient/issues/detail?id=1581
TEST=compile program
#include <fcntl.h>
#include <stdio.h>
int main(void){
#ifndef _LARGEFILE64_SOURCE
#warning "no _LARGEFILE64_SOURCE"
#endif
return 0;
}
Review URL: http://codereview.chromium.org/6770007