Skip to content

Commit e81d36c

Browse files
committed
picolibc: linker script: Add '__lcxx_override' section
This section was added into libc++ and conains the "new" operator[1]. Placing the "new" operator in the section allows checking, if the operator (defined as weak symbol) was overridden. The check relies on the "__start_" and "__end_" symbols generated by linker. These symbols would not be generated for names, which are not valid C identifiers. For this reason name like ".text.__lcxx_generated" cannot be used. [1] llvm/llvm-project#69498
1 parent f540d2b commit e81d36c

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

patches/picolibc.patch

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
diff --git a/meson.build b/meson.build
2-
index d82736966..55105b25c 100644
2+
index 0fdfa0412..8e679f166 100644
33
--- a/meson.build
44
+++ b/meson.build
5-
@@ -1212,6 +1212,18 @@ if get_option('newlib-retargetable-locking') != get_option('newlib-multithread')
5+
@@ -1224,6 +1224,18 @@ if get_option('newlib-retargetable-locking') != get_option('newlib-multithread')
66
error('newlib-retargetable-locking and newlib-multithread must be set to the same value')
77
endif
88

@@ -21,3 +21,15 @@ index d82736966..55105b25c 100644
2121
conf_data.set('_HAVE_CC_INHIBIT_LOOP_TO_LIBCALL',
2222
cc.has_argument('-fno-tree-loop-distribute-patterns'),
2323
description: 'Compiler flag to prevent detecting memcpy/memset patterns')
24+
diff --git a/picolibc.ld.in b/picolibc.ld.in
25+
index b97ea3300..e1a1318a2 100644
26+
--- a/picolibc.ld.in
27+
+++ b/picolibc.ld.in
28+
@@ -68,6 +68,7 @@ SECTIONS
29+
*(.text.unlikely .text.unlikely.*)
30+
*(.text.startup .text.startup.*)
31+
*(.text .text.* .opd .opd.*)
32+
+ *(__lcxx_override)
33+
*(.gnu.linkonce.t.*)
34+
KEEP (*(.fini .fini.*))
35+
@PREFIX@__text_end = .;

0 commit comments

Comments
 (0)