Skip to content

Commit 56c7d97

Browse files
committed
feat: add libc rom linker files
1 parent 946d181 commit 56c7d97

22 files changed

+657
-7
lines changed

example/stub_main.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <stdint.h>
88
#include <stdarg.h>
99
#include <stddef.h>
10+
#include <string.h>
1011

1112
#include <esp-stub-lib/log.h>
1213
#include <esp-stub-lib/flash.h>
@@ -48,7 +49,9 @@ static __attribute__((unused)) int handle_test2(va_list ap)
4849
{
4950
(void)ap;
5051

51-
STUB_LOG("test2\n");
52+
char buf[10];
53+
strcpy(buf, "test2\n");
54+
STUB_LOG(buf);
5255

5356
return 0;
5457
}

src/esp32/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ target_include_directories(${ESP_TARGET_LIB}
1111
)
1212

1313
target_link_options(${ESP_TARGET_LIB} PUBLIC -T${CMAKE_CURRENT_LIST_DIR}/ld/esp32.rom.ld)
14+
target_link_options(${ESP_TARGET_LIB} PUBLIC -T${CMAKE_CURRENT_LIST_DIR}/ld/esp32.rom.libc-funcs.ld)

src/esp32/ld/esp32.rom.libc-funcs.ld

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/* These are the newlib functions present in ESP32 ROM.
2+
They should not be used when compiling with PSRAM cache workaround enabled.
3+
See also esp32.rom.newlib-data.ld for the list of .data/.bss symbols
4+
used by these functions, and esp32.rom.newlib-nano.ld for "nano" versions
5+
of printf/scanf family of functions.
6+
7+
Unlike other ROM functions which are exported using PROVIDE, which declares
8+
weak symbols, newlib related functions are exported using assignment,
9+
which declares strong symbols. This is done so that ROM functions are always
10+
used instead of the ones provided by libc.a.
11+
12+
Time functions were moved to the esp32.rom.newlib-time.ld file.
13+
*/
14+
15+
abs = 0x40056340;
16+
bzero = 0x4000c1f4;
17+
div = 0x40056348;
18+
__dummy_lock = 0x4000c728;
19+
__dummy_lock_try = 0x4000c730;
20+
isalnum = 0x40000f04;
21+
isalpha = 0x40000f18;
22+
isascii = 0x4000c20c;
23+
isblank = 0x40000f2c;
24+
iscntrl = 0x40000f50;
25+
isdigit = 0x40000f64;
26+
isgraph = 0x40000f94;
27+
islower = 0x40000f78;
28+
isprint = 0x40000fa8;
29+
ispunct = 0x40000fc0;
30+
isspace = 0x40000fd4;
31+
isupper = 0x40000fe8;
32+
__itoa = 0x40056678;
33+
itoa = 0x400566b4;
34+
labs = 0x40056370;
35+
ldiv = 0x40056378;
36+
longjmp = 0x400562cc;
37+
memccpy = 0x4000c220;
38+
memchr = 0x4000c244;
39+
memcmp = 0x4000c260;
40+
memcpy = 0x4000c2c8;
41+
memmove = 0x4000c3c0;
42+
memrchr = 0x4000c400;
43+
memset = 0x4000c44c;
44+
qsort = 0x40056424;
45+
__sccl = 0x4000c498;
46+
setjmp = 0x40056268;
47+
strcasecmp = 0x400011cc;
48+
strcasestr = 0x40001210;
49+
strcat = 0x4000c518;
50+
strchr = 0x4000c53c;
51+
strcmp = 0x40001274;
52+
strcoll = 0x40001398;
53+
strcpy = 0x400013ac;
54+
strcspn = 0x4000c558;
55+
strlcat = 0x40001470;
56+
strlcpy = 0x4000c584;
57+
strlen = 0x400014c0;
58+
strlwr = 0x40001524;
59+
strncasecmp = 0x40001550;
60+
strncat = 0x4000c5c4;
61+
strncmp = 0x4000c5f4;
62+
strncpy = 0x400015d4;
63+
strnlen = 0x4000c628;
64+
strrchr = 0x40001708;
65+
strsep = 0x40001734;
66+
strspn = 0x4000c648;
67+
strstr = 0x4000c674;
68+
strupr = 0x4000174c;
69+
__submore = 0x40058f3c;
70+
toascii = 0x4000c720;
71+
tolower = 0x40001868;
72+
toupper = 0x40001884;
73+
__utoa = 0x400561f0;
74+
utoa = 0x40056258;

src/esp32c2/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ target_include_directories(${ESP_TARGET_LIB}
1111
)
1212

1313
target_link_options(${ESP_TARGET_LIB} PUBLIC -T${CMAKE_CURRENT_LIST_DIR}/ld/esp32c2.rom.ld)
14+
target_link_options(${ESP_TARGET_LIB} PUBLIC -T${CMAKE_CURRENT_LIST_DIR}/ld/esp32c2.rom.libc.ld)

src/esp32c2/ld/esp32c2.rom.ld

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
/*
2-
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
3-
*
4-
* SPDX-License-Identifier: Apache-2.0
5-
*/
6-
71
/* ROM function interface esp32c2.rom.ld for esp32c2
82
*
93
*

src/esp32c2/ld/esp32c2.rom.libc.ld

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
esp_rom_newlib_init_common_mutexes = 0x40000484;
2+
memset = 0x40000488;
3+
memcpy = 0x4000048c;
4+
memmove = 0x40000490;
5+
memcmp = 0x40000494;
6+
strcpy = 0x40000498;
7+
strncpy = 0x4000049c;
8+
strcmp = 0x400004a0;
9+
strncmp = 0x400004a4;
10+
strlen = 0x400004a8;
11+
strstr = 0x400004ac;
12+
bzero = 0x400004b0;
13+
sbrk = 0x400004b8;
14+
isalnum = 0x400004bc;
15+
isalpha = 0x400004c0;
16+
isascii = 0x400004c4;
17+
isblank = 0x400004c8;
18+
iscntrl = 0x400004cc;
19+
isdigit = 0x400004d0;
20+
islower = 0x400004d4;
21+
isgraph = 0x400004d8;
22+
isprint = 0x400004dc;
23+
ispunct = 0x400004e0;
24+
isspace = 0x400004e4;
25+
isupper = 0x400004e8;
26+
toupper = 0x400004ec;
27+
tolower = 0x400004f0;
28+
toascii = 0x400004f4;
29+
memccpy = 0x400004f8;
30+
memchr = 0x400004fc;
31+
memrchr = 0x40000500;
32+
strcasecmp = 0x40000504;
33+
strcasestr = 0x40000508;
34+
strcat = 0x4000050c;
35+
strchr = 0x40000514;
36+
strcspn = 0x40000518;
37+
strcoll = 0x4000051c;
38+
strlcat = 0x40000520;
39+
strlcpy = 0x40000524;
40+
strlwr = 0x40000528;
41+
strncasecmp = 0x4000052c;
42+
strncat = 0x40000530;
43+
strnlen = 0x40000538;
44+
strrchr = 0x4000053c;
45+
strsep = 0x40000540;
46+
strspn = 0x40000544;
47+
strtok_r = 0x40000548;
48+
strupr = 0x4000054c;
49+
longjmp = 0x40000550;
50+
setjmp = 0x40000554;
51+
abs = 0x40000558;
52+
div = 0x4000055c;
53+
labs = 0x40000560;
54+
ldiv = 0x40000564;
55+
qsort = 0x40000568;
56+
utoa = 0x40000578;
57+
itoa = 0x4000057c;
58+
__match = 0x400005dc;
59+
__hexnan = 0x400005e0;
60+
__hexdig_fun = 0x400005e4;
61+
__gethex = 0x400005e8;
62+
_Balloc = 0x400005ec;
63+
_Bfree = 0x400005f0;
64+
__multadd = 0x400005f4;
65+
__s2b = 0x400005f8;
66+
__hi0bits = 0x400005fc;
67+
__lo0bits = 0x40000600;
68+
__i2b = 0x40000604;
69+
__multiply = 0x40000608;
70+
__pow5mult = 0x4000060c;
71+
__lshift = 0x40000610;
72+
__mcmp = 0x40000614;
73+
__mdiff = 0x40000618;
74+
__ulp = 0x4000061c;
75+
__b2d = 0x40000620;
76+
__d2b = 0x40000624;
77+
__ratio = 0x40000628;
78+
_mprec_log10 = 0x4000062c;
79+
__copybits = 0x40000630;
80+
__any_on = 0x40000634;
81+
nan = 0x40000668;
82+
nanf = 0x4000066c;
83+
/* Data (.data, .bss, .rodata) */
84+
syscall_table_ptr = 0x3fcdffd8;
85+
_global_impure_ptr = 0x3fcdffd4;

src/esp32c3/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ target_include_directories(${ESP_TARGET_LIB}
1111
)
1212

1313
target_link_options(${ESP_TARGET_LIB} PUBLIC -T${CMAKE_CURRENT_LIST_DIR}/ld/esp32c3.rom.ld)
14+
target_link_options(${ESP_TARGET_LIB} PUBLIC -T${CMAKE_CURRENT_LIST_DIR}/ld/esp32c3.rom.libc.ld)

src/esp32c3/ld/esp32c3.rom.libc.ld

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
esp_rom_newlib_init_common_mutexes = 0x40000350;
2+
memset = 0x40000354;
3+
memcpy = 0x40000358;
4+
memmove = 0x4000035c;
5+
memcmp = 0x40000360;
6+
strcpy = 0x40000364;
7+
strncpy = 0x40000368;
8+
strcmp = 0x4000036c;
9+
strncmp = 0x40000370;
10+
strlen = 0x40000374;
11+
strstr = 0x40000378;
12+
bzero = 0x4000037c;
13+
sbrk = 0x40000384;
14+
isalnum = 0x40000388;
15+
isalpha = 0x4000038c;
16+
isascii = 0x40000390;
17+
isblank = 0x40000394;
18+
iscntrl = 0x40000398;
19+
isdigit = 0x4000039c;
20+
islower = 0x400003a0;
21+
isgraph = 0x400003a4;
22+
isprint = 0x400003a8;
23+
ispunct = 0x400003ac;
24+
isspace = 0x400003b0;
25+
isupper = 0x400003b4;
26+
toupper = 0x400003b8;
27+
tolower = 0x400003bc;
28+
toascii = 0x400003c0;
29+
memccpy = 0x400003c4;
30+
memchr = 0x400003c8;
31+
memrchr = 0x400003cc;
32+
strcasecmp = 0x400003d0;
33+
strcasestr = 0x400003d4;
34+
strcat = 0x400003d8;
35+
strchr = 0x400003e0;
36+
strcspn = 0x400003e4;
37+
strcoll = 0x400003e8;
38+
strlcat = 0x400003ec;
39+
strlcpy = 0x400003f0;
40+
strlwr = 0x400003f4;
41+
strncasecmp = 0x400003f8;
42+
strncat = 0x400003fc;
43+
strnlen = 0x40000404;
44+
strrchr = 0x40000408;
45+
strsep = 0x4000040c;
46+
strspn = 0x40000410;
47+
strtok_r = 0x40000414;
48+
strupr = 0x40000418;
49+
longjmp = 0x4000041c;
50+
setjmp = 0x40000420;
51+
abs = 0x40000424;
52+
div = 0x40000428;
53+
labs = 0x4000042c;
54+
ldiv = 0x40000430;
55+
qsort = 0x40000434;
56+
utoa = 0x40000444;
57+
itoa = 0x40000448;
58+
/* Data (.data, .bss, .rodata) */
59+
syscall_table_ptr = 0x3fcdffe0;
60+
_global_impure_ptr = 0x3fcdffdc;

src/esp32c5/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ target_include_directories(${ESP_TARGET_LIB}
1111
)
1212

1313
target_link_options(${ESP_TARGET_LIB} PUBLIC -T${CMAKE_CURRENT_LIST_DIR}/ld/esp32c5.rom.ld)
14+
target_link_options(${ESP_TARGET_LIB} PUBLIC -T${CMAKE_CURRENT_LIST_DIR}/ld/esp32c5.rom.libc.ld)

src/esp32c5/ld/esp32c5.rom.libc.ld

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
esp_rom_newlib_init_common_mutexes = 0x400004b4;
2+
memset = 0x400004b8;
3+
memcpy = 0x400004bc;
4+
memmove = 0x400004c0;
5+
memcmp = 0x400004c4;
6+
strcpy = 0x400004c8;
7+
strncpy = 0x400004cc;
8+
strcmp = 0x400004d0;
9+
strncmp = 0x400004d4;
10+
strlen = 0x400004d8;
11+
strstr = 0x400004dc;
12+
bzero = 0x400004e0;
13+
sbrk = 0x400004e8;
14+
isalnum = 0x400004ec;
15+
isalpha = 0x400004f0;
16+
isascii = 0x400004f4;
17+
isblank = 0x400004f8;
18+
iscntrl = 0x400004fc;
19+
isdigit = 0x40000500;
20+
islower = 0x40000504;
21+
isgraph = 0x40000508;
22+
isprint = 0x4000050c;
23+
ispunct = 0x40000510;
24+
isspace = 0x40000514;
25+
isupper = 0x40000518;
26+
toupper = 0x4000051c;
27+
tolower = 0x40000520;
28+
toascii = 0x40000524;
29+
memccpy = 0x40000528;
30+
memchr = 0x4000052c;
31+
memrchr = 0x40000530;
32+
strcasecmp = 0x40000534;
33+
strcasestr = 0x40000538;
34+
strcat = 0x4000053c;
35+
strchr = 0x40000544;
36+
strcspn = 0x40000548;
37+
strcoll = 0x4000054c;
38+
strlcat = 0x40000550;
39+
strlcpy = 0x40000554;
40+
strlwr = 0x40000558;
41+
strncasecmp = 0x4000055c;
42+
strncat = 0x40000560;
43+
strnlen = 0x40000568;
44+
strrchr = 0x4000056c;
45+
strsep = 0x40000570;
46+
strspn = 0x40000574;
47+
strtok_r = 0x40000578;
48+
strupr = 0x4000057c;
49+
longjmp = 0x40000580;
50+
setjmp = 0x40000584;
51+
abs = 0x40000588;
52+
div = 0x4000058c;
53+
labs = 0x40000590;
54+
ldiv = 0x40000594;
55+
qsort = 0x40000598;
56+
utoa = 0x400005a8;
57+
itoa = 0x400005ac;
58+
/* Data (.data, .bss, .rodata) */
59+
syscall_table_ptr = 0x4085ffd4;
60+
_global_impure_ptr = 0x4085ffd0;

src/esp32c6/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ target_include_directories(${ESP_TARGET_LIB}
1111
)
1212

1313
target_link_options(${ESP_TARGET_LIB} PUBLIC -T${CMAKE_CURRENT_LIST_DIR}/ld/esp32c6.rom.ld)
14+
target_link_options(${ESP_TARGET_LIB} PUBLIC -T${CMAKE_CURRENT_LIST_DIR}/ld/esp32c6.rom.libc.ld)

src/esp32c6/ld/esp32c6.rom.libc.ld

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
esp_rom_newlib_init_common_mutexes = 0x400004a4;
2+
memset = 0x400004a8;
3+
memcpy = 0x400004ac;
4+
memmove = 0x400004b0;
5+
memcmp = 0x400004b4;
6+
strcpy = 0x400004b8;
7+
strncpy = 0x400004bc;
8+
strcmp = 0x400004c0;
9+
strncmp = 0x400004c4;
10+
strlen = 0x400004c8;
11+
strstr = 0x400004cc;
12+
bzero = 0x400004d0;
13+
sbrk = 0x400004d8;
14+
isalnum = 0x400004dc;
15+
isalpha = 0x400004e0;
16+
isascii = 0x400004e4;
17+
isblank = 0x400004e8;
18+
iscntrl = 0x400004ec;
19+
isdigit = 0x400004f0;
20+
islower = 0x400004f4;
21+
isgraph = 0x400004f8;
22+
isprint = 0x400004fc;
23+
ispunct = 0x40000500;
24+
isspace = 0x40000504;
25+
isupper = 0x40000508;
26+
toupper = 0x4000050c;
27+
tolower = 0x40000510;
28+
toascii = 0x40000514;
29+
memccpy = 0x40000518;
30+
memchr = 0x4000051c;
31+
memrchr = 0x40000520;
32+
strcasecmp = 0x40000524;
33+
strcasestr = 0x40000528;
34+
strcat = 0x4000052c;
35+
strchr = 0x40000534;
36+
strcspn = 0x40000538;
37+
strcoll = 0x4000053c;
38+
strlcat = 0x40000540;
39+
strlcpy = 0x40000544;
40+
strlwr = 0x40000548;
41+
strncasecmp = 0x4000054c;
42+
strncat = 0x40000550;
43+
strnlen = 0x40000558;
44+
strrchr = 0x4000055c;
45+
strsep = 0x40000560;
46+
strspn = 0x40000564;
47+
strtok_r = 0x40000568;
48+
strupr = 0x4000056c;
49+
longjmp = 0x40000570;
50+
setjmp = 0x40000574;
51+
abs = 0x40000578;
52+
div = 0x4000057c;
53+
labs = 0x40000580;
54+
ldiv = 0x40000584;
55+
qsort = 0x40000588;
56+
utoa = 0x40000598;
57+
itoa = 0x4000059c;
58+
/* Data (.data, .bss, .rodata) */
59+
syscall_table_ptr = 0x4087ffd4;
60+
_global_impure_ptr = 0x4087ffd0;

0 commit comments

Comments
 (0)