Skip to content

Commit 689230b

Browse files
ratat-8ch
authored andcommitted
tools/nolibc/string: export strlen()
As with commit 8d304a3, "tools/nolibc/string: export memset() and memmove()", gcc -Os without -ffreestanding may fail to compile with: cc -fno-asynchronous-unwind-tables -fno-ident -s -Os -nostdlib -lgcc -static -o test test.c /usr/bin/ld: /tmp/cccIasKL.o: in function `main': test.c:(.text.startup+0x1e): undefined reference to `strlen' collect2: error: ld returned 1 exit status As on the aforementioned commit, this patch adds a section to export this function so compilation works on those cases too. Signed-off-by: Rodrigo Campos <[email protected]> Signed-off-by: Thomas Weißschuh <[email protected]>
1 parent 791f464 commit 689230b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/include/nolibc/string.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ char *strcpy(char *dst, const char *src)
123123
* thus itself, hence the asm() statement below that's meant to disable this
124124
* confusing practice.
125125
*/
126-
static __attribute__((unused))
126+
__attribute__((weak,unused,section(".text.nolibc_strlen")))
127127
size_t strlen(const char *str)
128128
{
129129
size_t len;

0 commit comments

Comments
 (0)