Skip to content

Commit 346510a

Browse files
committed
feat: add libc rom linker files
1 parent 946d181 commit 346510a

21 files changed

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

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
esp_rom_newlib_init_common_mutexes = 0x40000484;
7+
memset = 0x40000488;
8+
memcpy = 0x4000048c;
9+
memmove = 0x40000490;
10+
memcmp = 0x40000494;
11+
strcpy = 0x40000498;
12+
strncpy = 0x4000049c;
13+
strcmp = 0x400004a0;
14+
strncmp = 0x400004a4;
15+
strlen = 0x400004a8;
16+
strstr = 0x400004ac;
17+
bzero = 0x400004b0;
18+
sbrk = 0x400004b8;
19+
isalnum = 0x400004bc;
20+
isalpha = 0x400004c0;
21+
isascii = 0x400004c4;
22+
isblank = 0x400004c8;
23+
iscntrl = 0x400004cc;
24+
isdigit = 0x400004d0;
25+
islower = 0x400004d4;
26+
isgraph = 0x400004d8;
27+
isprint = 0x400004dc;
28+
ispunct = 0x400004e0;
29+
isspace = 0x400004e4;
30+
isupper = 0x400004e8;
31+
toupper = 0x400004ec;
32+
tolower = 0x400004f0;
33+
toascii = 0x400004f4;
34+
memccpy = 0x400004f8;
35+
memchr = 0x400004fc;
36+
memrchr = 0x40000500;
37+
strcasecmp = 0x40000504;
38+
strcasestr = 0x40000508;
39+
strcat = 0x4000050c;
40+
strchr = 0x40000514;
41+
strcspn = 0x40000518;
42+
strcoll = 0x4000051c;
43+
strlcat = 0x40000520;
44+
strlcpy = 0x40000524;
45+
strlwr = 0x40000528;
46+
strncasecmp = 0x4000052c;
47+
strncat = 0x40000530;
48+
strnlen = 0x40000538;
49+
strrchr = 0x4000053c;
50+
strsep = 0x40000540;
51+
strspn = 0x40000544;
52+
strtok_r = 0x40000548;
53+
strupr = 0x4000054c;
54+
longjmp = 0x40000550;
55+
setjmp = 0x40000554;
56+
abs = 0x40000558;
57+
div = 0x4000055c;
58+
labs = 0x40000560;
59+
ldiv = 0x40000564;
60+
qsort = 0x40000568;
61+
utoa = 0x40000578;
62+
itoa = 0x4000057c;
63+
__match = 0x400005dc;
64+
__hexnan = 0x400005e0;
65+
__hexdig_fun = 0x400005e4;
66+
__gethex = 0x400005e8;
67+
_Balloc = 0x400005ec;
68+
_Bfree = 0x400005f0;
69+
__multadd = 0x400005f4;
70+
__s2b = 0x400005f8;
71+
__hi0bits = 0x400005fc;
72+
__lo0bits = 0x40000600;
73+
__i2b = 0x40000604;
74+
__multiply = 0x40000608;
75+
__pow5mult = 0x4000060c;
76+
__lshift = 0x40000610;
77+
__mcmp = 0x40000614;
78+
__mdiff = 0x40000618;
79+
__ulp = 0x4000061c;
80+
__b2d = 0x40000620;
81+
__d2b = 0x40000624;
82+
__ratio = 0x40000628;
83+
_mprec_log10 = 0x4000062c;
84+
__copybits = 0x40000630;
85+
__any_on = 0x40000634;
86+
nan = 0x40000668;
87+
nanf = 0x4000066c;
88+
/* Data (.data, .bss, .rodata) */
89+
syscall_table_ptr = 0x3fcdffd8;
90+
_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: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
esp_rom_newlib_init_common_mutexes = 0x40000350;
7+
memset = 0x40000354;
8+
memcpy = 0x40000358;
9+
memmove = 0x4000035c;
10+
memcmp = 0x40000360;
11+
strcpy = 0x40000364;
12+
strncpy = 0x40000368;
13+
strcmp = 0x4000036c;
14+
strncmp = 0x40000370;
15+
strlen = 0x40000374;
16+
strstr = 0x40000378;
17+
bzero = 0x4000037c;
18+
sbrk = 0x40000384;
19+
isalnum = 0x40000388;
20+
isalpha = 0x4000038c;
21+
isascii = 0x40000390;
22+
isblank = 0x40000394;
23+
iscntrl = 0x40000398;
24+
isdigit = 0x4000039c;
25+
islower = 0x400003a0;
26+
isgraph = 0x400003a4;
27+
isprint = 0x400003a8;
28+
ispunct = 0x400003ac;
29+
isspace = 0x400003b0;
30+
isupper = 0x400003b4;
31+
toupper = 0x400003b8;
32+
tolower = 0x400003bc;
33+
toascii = 0x400003c0;
34+
memccpy = 0x400003c4;
35+
memchr = 0x400003c8;
36+
memrchr = 0x400003cc;
37+
strcasecmp = 0x400003d0;
38+
strcasestr = 0x400003d4;
39+
strcat = 0x400003d8;
40+
strchr = 0x400003e0;
41+
strcspn = 0x400003e4;
42+
strcoll = 0x400003e8;
43+
strlcat = 0x400003ec;
44+
strlcpy = 0x400003f0;
45+
strlwr = 0x400003f4;
46+
strncasecmp = 0x400003f8;
47+
strncat = 0x400003fc;
48+
strnlen = 0x40000404;
49+
strrchr = 0x40000408;
50+
strsep = 0x4000040c;
51+
strspn = 0x40000410;
52+
strtok_r = 0x40000414;
53+
strupr = 0x40000418;
54+
longjmp = 0x4000041c;
55+
setjmp = 0x40000420;
56+
abs = 0x40000424;
57+
div = 0x40000428;
58+
labs = 0x4000042c;
59+
ldiv = 0x40000430;
60+
qsort = 0x40000434;
61+
utoa = 0x40000444;
62+
itoa = 0x40000448;
63+
/* Data (.data, .bss, .rodata) */
64+
syscall_table_ptr = 0x3fcdffe0;
65+
_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: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
esp_rom_newlib_init_common_mutexes = 0x400004b4;
7+
memset = 0x400004b8;
8+
memcpy = 0x400004bc;
9+
memmove = 0x400004c0;
10+
memcmp = 0x400004c4;
11+
strcpy = 0x400004c8;
12+
strncpy = 0x400004cc;
13+
strcmp = 0x400004d0;
14+
strncmp = 0x400004d4;
15+
strlen = 0x400004d8;
16+
strstr = 0x400004dc;
17+
bzero = 0x400004e0;
18+
sbrk = 0x400004e8;
19+
isalnum = 0x400004ec;
20+
isalpha = 0x400004f0;
21+
isascii = 0x400004f4;
22+
isblank = 0x400004f8;
23+
iscntrl = 0x400004fc;
24+
isdigit = 0x40000500;
25+
islower = 0x40000504;
26+
isgraph = 0x40000508;
27+
isprint = 0x4000050c;
28+
ispunct = 0x40000510;
29+
isspace = 0x40000514;
30+
isupper = 0x40000518;
31+
toupper = 0x4000051c;
32+
tolower = 0x40000520;
33+
toascii = 0x40000524;
34+
memccpy = 0x40000528;
35+
memchr = 0x4000052c;
36+
memrchr = 0x40000530;
37+
strcasecmp = 0x40000534;
38+
strcasestr = 0x40000538;
39+
strcat = 0x4000053c;
40+
strchr = 0x40000544;
41+
strcspn = 0x40000548;
42+
strcoll = 0x4000054c;
43+
strlcat = 0x40000550;
44+
strlcpy = 0x40000554;
45+
strlwr = 0x40000558;
46+
strncasecmp = 0x4000055c;
47+
strncat = 0x40000560;
48+
strnlen = 0x40000568;
49+
strrchr = 0x4000056c;
50+
strsep = 0x40000570;
51+
strspn = 0x40000574;
52+
strtok_r = 0x40000578;
53+
strupr = 0x4000057c;
54+
longjmp = 0x40000580;
55+
setjmp = 0x40000584;
56+
abs = 0x40000588;
57+
div = 0x4000058c;
58+
labs = 0x40000590;
59+
ldiv = 0x40000594;
60+
qsort = 0x40000598;
61+
utoa = 0x400005a8;
62+
itoa = 0x400005ac;
63+
/* Data (.data, .bss, .rodata) */
64+
syscall_table_ptr = 0x4085ffd4;
65+
_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)

0 commit comments

Comments
 (0)