3727 Commits

Author SHA1 Message Date
Rich Felker
ef2b5e9f13 fix unlikely corner cases in getopt's message printing
like fputs (see commit 10a17dfbad2c267d885817abc9c7589fc7ff630b), the
message printing code for getopt assumed that fwrite only returns 0 on
failure, but it can also happen on success if the total length to be
written is zero. programs with zero-length argv[0] were affected.

commit 500c6886c654fd45e4926990fee2c61d816be197 introduced this
problem in getopt by fixing the fwrite behavior to conform to the
requirements of ISO C. previously the wrong expectations of the getopt
code were met by the fwrite implementation.
2016-02-16 13:27:24 -05:00
Rich Felker
10a17dfbad fix assumption in fputs that fwrite returning 0 implies an error
internally, the idiom of passing nmemb=1 to fwrite and interpreting
the return value of fwrite (which is necessarily 0 or 1) as
failure/success is fairly widely used. this is not correct, however,
when the size argument is unknown and may be zero, since C requires
fwrite to return 0 in that special case. previously fwrite always
returned nmemb on success, but this was changed for conformance with
ISO C by commit 500c6886c654fd45e4926990fee2c61d816be197.
2016-02-16 13:26:16 -05:00
Rich Felker
9c102700a7 release 1.1.13 2016-02-15 23:12:42 -05:00
JF Bastien
1648814783 Add clrsbl clrsbll as well 2016-02-14 14:08:20 -08:00
JF Bastien
49dbb74456 Add __builtin_clrsb as NYI
builtin-bitops-1.c now hits it.
2016-02-13 13:57:29 -08:00
Rich Felker
0ed932f34f do not define static_assert macro for pre-C11 compilers
some software simply uses static_assert if the macro is defined, and
this breaks if the compiler does not recognize the _Static_assert
keyword used to define it.
2016-02-12 10:11:40 -05:00
Rich Felker
692b16d14b add declarations for utmpname/utmpxname to appropriate headers
commit 378f8cb5222b63e4f8532c757ce54e4074567e1f added these functions
(as stubs) but left them without declarations. this broke some
autoconf based software that detected linkability of the symbols but
didn't check for a declaration.
2016-02-12 09:58:50 -05:00
Rich Felker
500c6886c6 fix return value for fread/fwrite when size argument is 0
when the size argument was zero but nmemb was nonzero, these functions
were returning nmemb, despite no data having been written.
conceptually this is not wrong, but the standard requires a return
value of zero in this case.
2016-02-10 19:44:19 -05:00
Rich Felker
416d1c7a71 fix line-buffered flush omission for odd usage of putc-family functions
as specified, the int argument providing the character to write is
converted to type unsigned char. for the actual write to buffer,
conversion happened implicitly via the assignment operator; however,
the logic to check whether the argument was a newline used the
original int value. thus usage such as putchar('\n'+0x100) failed to
produce a flush.
2016-02-10 19:10:34 -05:00
Rich Felker
5a6e8d098a fix failed write reporting by fwrite in line-buffered mode
when a write error occurred while flushing output due to a newline,
fwrite falsely reported all bytes up to and including the newline as
successfully written. in general, due to buffering such "spurious
success" returns are acceptable for stdio; however for line-buffered
mode it was subtly wrong. errors were still visible via ferror() or as
a short-write return if there was more data past the newline that
should have been written, but since the contract for line-buffered
mode is that everything up through the newline be written out
immediately, a discrepency was observable in the actual file contents.
2016-02-10 13:51:05 -05:00
Rich Felker
869a9df5b5 remove workaround for broken mips assemblers
the workaround was for a bug that botched .gpword references to local
labels, applying a nonsensical random offset of -0x4000 to them.

this reverses commit 5e396fb996a80b035d0f6ecf7fed50f68aa3ebb7 and a
removes a similar hack that was added to syscall_cp.s in the later
commit 756c8af8589265e99e454fe3adcda1d0bc5e1963. it turns out one
additional instance of the same idiom, the GETFUNCSYM macro in
arch/mips/reloc.h, was still affected by the assembler bug and does
not admit an easy workaround without making assumptions about how the
macro is used. the previous workarounds made static linking work but
left the early-stage dynamic linker broken and thus had limited
usefulness.

instead, affected users (using binutils versions older than 2.20) will
need to fix the bug on the binutils side; the trivial patch is commit
453f5985b13e35161984bf1bf657bbab11515aa4 in the binutils-gdb
repository.
2016-02-08 21:07:09 +00:00
Rich Felker
756c8af858 in mips cancellable syscall asm, don't assume gp register is valid
the old __cp_cancel code path loaded the address of __cancel from the
GOT using the $gp register, which happened to be set to point to the
correct GOT by the calling C function, but there is no ABI requirement
that this happen. instead, go the roundabout way and compute the
address of __cancel via pc-relative and gp-relative addressing
starting with a fake return address generated by a bal instruction,
which is the same trick crt1 uses to bootstrap.
2016-02-04 23:01:03 +00:00
Rich Felker
aecda35373 avoid using signals when a thread attempts to cancel itself
not only is pthread_kill expensive in this case; it also breaks
testing under qemu app-level emulation.
2016-02-04 22:59:13 +00:00
JF Bastien
968d8d2158 Improve trap handling, fix isspace. 2016-02-03 08:30:55 -08:00
JF Bastien
7f1742a8c3 Fix reference error. 2016-02-03 04:26:30 -08:00
JF Bastien
d8b373a605 Keep musl.bc
It can be used for static linking.
2016-02-03 02:27:12 -08:00
Rich Felker
47314f1e67 make configure accept -h as an alias for --help 2016-02-02 21:14:09 -05:00
Rich Felker
40891ae6db update INSTALL file with new archs, compiler info
add aarch64 and or1k archs, upgrade sh from experimental, and note
that sh now supports the FDPIC ABI.

the old advice on compiler versions was outdated and more specific
than made sense. presence of compiler bugs varies a lot by arch, so
it's hard to make any good recommendations beyond "recent". if we want
to document specific known-good/bad compiler versions, a much larger
section in the documentation than what's appropriate for the INSTALL
file would be needed.
2016-02-02 17:47:25 -05:00
JF Bastien
fb8c48cc01 Forgot one 'limited' 2016-02-01 11:25:19 -08:00
JF Bastien
38b698553b Include some feedback from Luke. 2016-02-01 11:14:27 -08:00
JF Bastien
ff04d7f6e7 More details on dlsym 2016-02-01 09:25:34 -08:00
JF Bastien
682407e272 dlsym: use same pattern as other loader
It's still broken because call_indirect requires a function in the same module.
2016-02-01 09:22:50 -08:00
JF Bastien
8bbb33957b Handle main() not returning EXIT_SUCCESS. 2016-02-01 08:26:21 -08:00
JF Bastien
290eda430d Note on segments overwriting each other. 2016-02-01 08:19:23 -08:00
JF Bastien
bbad041ac5 Don't build puts.c from musl
The JS one works, but C one needs syscalls to do anything useful.
2016-02-01 08:16:40 -08:00
JF Bastien
297c0c1395 More dlcall clarification. 2016-02-01 08:07:36 -08:00
JF Bastien
b94a60e174 dlcall trampoline clarification. 2016-02-01 08:06:32 -08:00
JF Bastien
f73845c1b8 Typo. 2016-02-01 08:05:12 -08:00
JF Bastien
0430d8d821 Add note on heap sharing. 2016-02-01 08:04:53 -08:00
JF Bastien
acc1d6453b dlfcn.h implementation and detailed example. 2016-02-01 08:00:42 -08:00
JF Bastien
13f9666606 Stub dlfcn.h 2016-02-01 04:54:06 -08:00
JF Bastien
68531e26b5 More readme content. 2016-02-01 04:46:05 -08:00
Szabolcs Nagy
d150764697 fix malloc_usable_size for NULL input
the linux man page specifies malloc_usable_size(0) to return 0 and
this is the semantics other implementations follow (jemalloc).
reported by Alexander Monakov.
2016-01-31 17:34:45 -05:00
Szabolcs Nagy
2810b30fc3 regex: increase the stack tre uses for tnfa creation
10k elements stack is increased to 1000k, otherwise tnfa creation fails
for reasonable sized patterns: a single literal char can add 7 elements
to this stack, so regcomp of an 1500 char long pattern (with only litral
chars) fails with REG_ESPACE. (the new limit allows about < 150k chars,
this arbitrary limit allows most command line regex usage.)

ideally there would be no upper bound: regcomp dynamically reallocates
this buffer, every reallocation checks for allocation failure and at
the end this stack is freed so there is no reason for special bound.
however that may have unwanted effect on regcomp and regexec runtime
so this is a conservative change.
2016-01-31 17:33:54 -05:00
Szabolcs Nagy
3b27725385 better a_sc inline asm constraint on aarch64 and arm
"Q" input constraint was used for the written object, instead of "=Q"
output constraint.  this should not cause problems because "memory"
is on the clobber list, but "=Q" better documents the intent and more
consistent with the actual asm code.

this changes the generated code, because different registers are used,
but other than the register names nothing should change.
2016-01-31 17:32:56 -05:00
JF Bastien
ee62761f12 Typo. 2016-01-31 12:41:25 -08:00
JF Bastien
e5d2fe138b Still more readme. 2016-01-31 12:39:00 -08:00
JF Bastien
5a74c85f16 More readme. 2016-01-31 12:36:42 -08:00
JF Bastien
2809b1ff41 Code quotes 2016-01-31 06:57:10 -08:00
JF Bastien
e2ce69a6fd Merge branch 'wasm-prototype-1' of github.com:WebAssembly/musl into wasm-prototype-1 2016-01-31 06:55:58 -08:00
JF Bastien
556002b394 Add README.md 2016-01-31 06:55:45 -08:00
JF Bastien
26e7adf5d0 wasm objects don't have hasOwnProperty and functions aren't Function 2016-01-31 02:49:24 -08:00
Rich Felker
65498f289b don't suppress shared libc when linker lacks -Bsymbolic-functions
previous work overhauling the dynamic linker made it so that linking
libc with -Bsymbolic-functions was no longer mandatory, but the
configure logic that forced --disable-shared when ld failed to accept
the option was left in place.

this commit removes the hard-coded -Bsymbolic-functions from the
Makefile and changes the configure test to one that simply adds it to
the auto-detected LDFLAGS on success.
2016-01-31 00:40:33 -05:00
Felix Fietkau
c18d05f0e8 ldso: fix GDB dynamic linker info on MIPS
GDB is looking for a pointer to the ldso debug info in the data of the
..rld_map section.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2016-01-30 20:55:22 -05:00
Szabolcs Nagy
831e9d9efa regex: simplify the {,} repetition parsing logic 2016-01-30 20:53:52 -05:00
Szabolcs Nagy
25160f1c08 regex: treat \+, \? as repetitions in BRE
These are undefined escape sequences by the standard, but often
used in sed scripts.
2016-01-30 20:53:42 -05:00
Szabolcs Nagy
03498ec22a regex: rewrite the repetition parsing code
The goto logic was hard to follow and modify. This is
in preparation for the BRE \+ and \? support.
2016-01-30 20:53:29 -05:00
Szabolcs Nagy
da4cc13b97 regex: treat \| in BRE as alternation
The standard does not define semantics for \| in BRE, but some code
depends on it meaning alternation. Empty alternative expression is
allowed to be consistent with ERE.

Based on a patch by Rob Landley.
2016-01-30 20:53:17 -05:00
Szabolcs Nagy
7eaa76fc2e regex: reject repetitions in some cases with REG_BADRPT
Previously repetitions were accepted after empty expressions like
in (*|?)|{2}, but in BRE the handling of * and \{\} were not
consistent: they were accepted as literals in some cases and
repetitions in others.

It is better to treat repetitions after an empty expression as an
error (this is allowed by the standard, and glibc mostly does the
same). This is hard to do consistently with the current logic so
the new rule is:

Reject repetitions after empty expressions, except after assertions
^*, $? and empty groups ()+ and never treat them as literals.

Empty alternation (|a) is undefined by the standard, but it can be
useful so that should be accepted.
2016-01-30 20:53:04 -05:00
Szabolcs Nagy
a8cc225384 regex: clean up position accounting for literal nodes
This should not change the meaning of the code, just make the intent
clearer: advancing position is tied to adding a new literal.
2016-01-30 20:51:58 -05:00