3748 Commits

Author SHA1 Message Date
Sam Clegg
cadbdd1be5 fix include installation 2018-02-06 13:21:35 -08:00
Sam Clegg
d32873dc43 fix include installations paths 2018-02-06 12:18:02 -08:00
Sam Clegg
413fe73ce2 Add cmake support
This change will allow us to remove the libc.py script and
build the wasm targets using cmake+ninja instead.
2018-02-06 11:28:35 -08:00
Sam Clegg
2b2b3bdbe3
[WebAssembly] wasm.js: use explicity variable for main_module (#43) 2018-01-22 15:18:08 -08:00
Sam Clegg
c93b284f39
[WebAssembly] Add call to __wasm_call_ctors on startup if found (#42) 2018-01-18 12:36:54 -08:00
Sam Clegg
ac877172c1
[WebAssembly] Add stub for _Unwind_ForcedUnwind (#41) 2018-01-17 19:24:15 -08:00
Sam Clegg
b93ae1f7eb [WebAssembly] Add TODO 2018-01-17 14:38:49 -08:00
Sam Clegg
dbd68988a8 [WebAssembly] Update PAGE_SIZE for 64k
See: 910e3cace5/Semantics.md (resizing)
2018-01-16 17:23:54 -08:00
Sam Clegg
9064441edc
[WebAssembly] Support grow memory in brk() (#39) 2018-01-16 17:20:44 -08:00
JF Bastien
2c356f0738
Merge pull request #37 from jfbastien/implment_brk
[WebAssembly] wasm.js: implement brk
2018-01-13 11:30:36 -08:00
Sam Clegg
ddb01fbf88 handle oom 2018-01-13 09:23:30 -08:00
Sam Clegg
3ce20a9f57 [WebAssembly] wasm.js: implement brk 2018-01-13 08:47:42 -08:00
Sam Clegg
0c827335e4
[WebAssebmly] Implement a_cas() in arch/wasm32/atomic_arch.h (#36) 2018-01-13 08:46:40 -08:00
Sam Clegg
0bf0e9f1fe
wasm.js: Add unwind symbols needed by libc++abi (#35) 2018-01-11 15:21:59 -08:00
Sam Clegg
4b17a3b40c
Rename wasm.syms -> libc.imports (#34) 2018-01-11 14:33:17 -08:00
JF Bastien
51733cacc7
Merge pull request #32 from dschuff/nodejs
Support node.js in wasm loader
2017-12-15 15:04:24 -08:00
Derek Schuff
190dffd141 remove extra logging 2017-12-15 13:23:12 -08:00
Derek Schuff
4b606b59d4 Support node.js in wasm loader
The latest LTS of Node supports wasm, and this allows us to test
against it, as well as the shells.
2017-12-13 15:53:52 -08:00
JF Bastien
e43efbe62d
Merge pull request #30 from jfbastien/remove_headers
[WebAssembly] Remove empty headers
2017-11-30 16:10:19 -08:00
Sam Clegg
14ffeeb5bb
[WebAssembly] Keep itermediate files (#31)
In particular we need to keep the generated headers around so they can be installed later.

This behavior mimics more closely what the musl Makefile does now that it supports out-of-tree
building (i.e. it puts all the generated files under obj)
2017-11-30 15:32:18 -08:00
Sam Clegg
c34cb0b46a [WebAssembly] Remove empty headers
These are provided by arch/generic.
2017-11-30 15:14:40 -08:00
JF Bastien
8977c9eba7
Merge pull request #29 from jfbastien/merge_master
Merge master
2017-11-29 22:44:01 -08:00
Sam Clegg
2b92b728e3 Merge remote-tracking branch 'upstream/master' into HEAD 2017-11-29 15:46:05 -08:00
Sam Clegg
b49da62f23
Implement writv syscall so that musl printf works (#26) 2017-11-20 17:13:33 -08:00
Szabolcs Nagy
72656157f5 fix fgetwc when decoding a character that crosses buffer boundary
Update the buffer position according to the bytes consumed into st when
decoding an incomplete character at the end of the buffer.
2017-11-18 20:11:08 -05:00
Sam Clegg
6a45034cab
[WebAssembly] Cleanup syscall handling in wasm.js (#25)
Also, ignore a couple of syscall by return 0 rather
than -1.  This allows the musl startup code to get
furthur.
2017-11-17 17:01:15 -08:00
Sam Clegg
1086c398e6
[WebAssembly] Add -Wno-empty-body to wasm build (#24)
This is needed to suppress new llvm warnings
2017-11-16 16:26:18 -08:00
Sam Clegg
0f2a7be58e
[WebAssembly] Add syscall numbers of wasm.js (#23)
I verified that this change doesn't change the list
of failing tests on the wasm waterfall.
2017-11-16 12:28:18 -08:00
Sam Clegg
9f20a8a3c2
[WebAsembly] Build thread code (#22) 2017-11-15 15:58:02 -08:00
Rich Felker
a223dbd27a add reverse iconv mappings for JIS-based encodings
these encodings are still commonly used in messaging protocols and
such. the reverse mapping is implemented as a binary search of a list
of the jis 0208 characters in unicode order; the existing forward
table is used to perform the comparison in the search.
2017-11-14 23:54:02 -05:00
Rich Felker
105eff9dec generalize iconv framework for 8-bit codepages
previously, 8-bit codepages could only remap the high 128 bytes; the
low range was assumed/forced to agree with ascii. interpretation of
codepage table headers has been changed so that it's possible to
represent mappings for up to 256 slots (fewer if the initial portion
of the map is elided because it coincides with unicode codepoints).
this requires consuming a bit more of the 10-bit space of characters
that can be represented in 8-bit codepages, but there's still a plenty
left. the size of the legacy_chars table is actually reduced now by
eliding the first 256 entries and considering them to map implicitly
via the identity map.

before these changes, there seem to have been minor bugs/omissions in
codepage table generation, so it's likely that some actual bug fixes
are silently included in this commit. round-trip testing of a few
codepages was performed on the new version of the code, but no
differential testing against the old version was done.
2017-11-13 18:34:27 -05:00
Rich Felker
a71b46cfd2 fix malloc state corruption when ldso rejects loading a second libc
commit c49d3c8adadfa24235fcf4779bb722b1aa6f480b added logic to detect
attempts to load libc.so via another name and instead redirect to the
existing libc, rather than loading two and producing dangerously
inconsistent state. however, the check for and unmapping of the
duplicate libc happened after reclaim_gaps was already called,
donating the slack space around the writable segment to malloc.
subsequent unmapping of the library then invalidated malloc's free
lists.

fix the issue by moving the call to reclaim_gaps out of map_library
into load_library, after the duplicate libc check but before the first
call to calloc, so that the gaps can still be used to satisfy the
allocation of struct dso. this change also eliminates the need for an
ugly hack (temporarily setting runtime=1) to avoid reclaim_gaps when
loading the main program via map_library, which happens when ldso is
invoked as a command.

only programs/libraries erroneously containing a DT_NEEDED reference
to libc.so via an absolute pathname or symlink were affected by this
issue.
2017-11-13 15:27:10 -05:00
Rich Felker
d060edf6c5 reformat cjk iconv tables to be diff-friendly, match tool output
the new version of the code used to generate these tables forces a
newline every 256 entries, whereas at the time these files were
originally generated and committed, it only wrapped them at 80
columns. the new behavior ensures that localized changes to the
tables, if they are ever needed, will produce localized diffs. other
tables including hkscs were already committed in the new format.

binary comparison of the generated object files was performed to
confirm that no spurious changes slipped in.
2017-11-11 02:04:30 -05:00
Bobby Bingham
c21051e90c prevent fork's errno from being clobbered by atfork handlers
If the syscall fails, errno must be set correctly for the caller.
There's no guarantee that the handlers registered with pthread_atfork
won't clobber errno, so we need to ensure it gets set after they are
called.
2017-11-10 19:27:57 -05:00
Rich Felker
a39f20bf9f add iso-2022-jp support (decoding only) to iconv
this implementation aims to match the baseline defined by rfc1468 (the
original mime charset definition) plus the halfwidth katakana
extension included in the whatwg definition of the charset. rejection
of si/so controls and newlines in doublebyte state are not currently
enforced. the jis x 0201 mode is currently interpreted as having the
yen sign and overline character in place of backslash and tilde; ascii
mode has the standard ascii characters in those slots.
2017-11-10 17:22:43 -05:00
Rich Felker
5b546faa67 add iconv framework for decoding stateful encodings
assuming pointers obtained from malloc have some nonzero alignment,
repurpose the low bit of iconv_t as an indicator that the descriptor
is a stateless value representing the source and destination character
encodings.
2017-11-10 15:06:42 -05:00
Rich Felker
0df5b39a1e simplify/optimize iconv utf-8 case
the special case where mbrtowc returns 0 but consumed 1 byte of input
does not need to be considered, because the short-circuit for low
bytes already covered that case.
2017-11-10 13:40:12 -05:00
Rich Felker
9eb6dd5165 handle ascii range individually in each iconv case
short-circuiting low bytes before the switch precluded support for
character encodings that don't coincide with ascii in this range. this
limitation affected iso-2022 encodings, which use the esc byte to
introduce a shift sequence, and things like ebcdic.
2017-11-10 13:34:21 -05:00
Rich Felker
bff59d13a8 move iconv_close to its own translation unit
this is in preparation to support stateful conversion descriptors,
which are necessarily allocated and thus must be freed in iconv_close.
putting it in a separate TU will avoid pulling in free if iconv_close
is not referenced.
2017-11-10 00:27:34 -05:00
Rich Felker
79f49effa0 refactor iconv conversion descriptor encoding/decoding
this change is made to avoid having assumptions about the encoding
spread out across the file, and to facilitate future change to a form
that can accommodate allocted, stateful descriptors when needed.

this commit should not produce any functional changes; with the
compiler tested the only change to code generation was minor
reordering of local variables on stack.
2017-11-10 00:15:09 -05:00
A. Wilcox
30fdda6c99 fix getaddrinfo error code for non-numeric service with AI_NUMERICSERV
If AI_NUMERICSERV is specified and a numeric service was not provided,
POSIX mandates getaddrinfo return EAI_NONAME. EAI_SERVICE is only for
services that cannot be used on the specified socket type.
2017-11-09 20:15:02 -05:00
Rich Felker
67b2994789 fix mismatched type of __pthread_tsd_run_dtors weak definition
commit a6054e3c94aa0491d7366e4b05ae0d73f661bfe2 changed this function
not to take an argument, but the weak definition used by timer_create
was not updated to match.

reported by Pascal Cuoq.
2017-11-09 19:56:26 -05:00
Sam Clegg
c185c68dd0
[WebAssembly] Use hardcoded list expected undefined symbols (#21)
Rather than generate wasm.syms from wasm.js (which includes
a huge superset of the number of symbols actaully expected
to be undefined at link time) simply hardcode that list as
a test file, which lld can read.
2017-11-07 15:17:25 -08:00
Sam Clegg
8116ebcd0c
[WebAssembly] Fix shared library loading (#17)
Loading of shared libraries was broken back in:
39fde60

This change restores the ability for shared libraries to
be loaded such that they can share memory and provide
function exports to the main executable.

However the executable that libraries still need to built
in a specific way (i.e. all importing the same sized memory)
and their static globals need to be in the different address
range. This has the complication that the executables won't
run the wasm spec interpreter (since it doesn't pass in a
memory to the executables it runs). So although I'm fixing this
here in the musl repo I'm also proposiing that we remove the
continuous testing of this configurations on the wasm waterfall
in favor of concentrating on the statically linking lld case:
WebAssembly/waterfall#271
2017-11-06 14:18:53 -08:00
Szabolcs Nagy
13935337f3 s390x: use generic ioctl.h
s390 can use the generic ioctls definitions other than FIOQSIZE (like arm).

this fixes some missing ioctls and two incorrect ones:
TIOCTTYGSTRUCT and TIOCM_MODEM_BITS seem to be defined on frv
target only in linux.
2017-11-05 18:43:51 -05:00
Szabolcs Nagy
4dc44ce8e2 microblaze: add statx syscall from linux v4.13
statx number is allocated for microblaze in linux commit
f5ef419630e85e80284cd0256cb5a13a66bbd6c5
2017-11-05 18:41:29 -05:00
Szabolcs Nagy
ffd048a07b aarch64: add extra_context struct from linux v4.13
allows expanding the signal frame beyond the 4k reserved space.
new in linux commit 33f082614c3443d937f50fe936f284f62bbb4a1b
2017-11-05 18:41:27 -05:00
Szabolcs Nagy
6651ef1f06 add new tcp.h socket options from linux v4.13
TCP_ULP is new in linux commit 734942cc4ea6478eed125af258da1bdbb4afe578
TCP_MD5SIG_EXT is new in 8917a777be3ba566377be05117f71b93a5fd909d
2017-11-05 18:41:26 -05:00
Szabolcs Nagy
14ced22830 add new fcntl.h macros from linux v4.13
for getting/setting write lifetime hints fcntl commands were
added in linux commit c75b1d9421f80f4143e389d2d50ddfc8a28c8c35

added under _GNU_SOURCE || _BSD_SOURCE, since RWH_* life time
hints are not in the POSIX reserved namespace.
2017-11-05 18:41:24 -05:00
Szabolcs Nagy
754f66afb7 ioctl TIOCGPTPEER from linux v4.13
added for safe opening of peer end of pty in a mount namespace.
new in linux commit c6325179238f1d4683edbec53d8322575d76d7e2
2017-11-05 18:41:22 -05:00