Skip to content

Commit

Permalink
picolibc: linker script: Add '__lcxx_override' section
Browse files Browse the repository at this point in the history
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
  • Loading branch information
domin144 committed Feb 22, 2024
1 parent f540d2b commit e81d36c
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions patches/picolibc.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git a/meson.build b/meson.build
index d82736966..55105b25c 100644
index 0fdfa0412..8e679f166 100644
--- a/meson.build
+++ b/meson.build
@@ -1212,6 +1212,18 @@ if get_option('newlib-retargetable-locking') != get_option('newlib-multithread')
@@ -1224,6 +1224,18 @@ if get_option('newlib-retargetable-locking') != get_option('newlib-multithread')
error('newlib-retargetable-locking and newlib-multithread must be set to the same value')
endif

Expand All @@ -21,3 +21,15 @@ index d82736966..55105b25c 100644
conf_data.set('_HAVE_CC_INHIBIT_LOOP_TO_LIBCALL',
cc.has_argument('-fno-tree-loop-distribute-patterns'),
description: 'Compiler flag to prevent detecting memcpy/memset patterns')
diff --git a/picolibc.ld.in b/picolibc.ld.in
index b97ea3300..e1a1318a2 100644
--- a/picolibc.ld.in
+++ b/picolibc.ld.in
@@ -68,6 +68,7 @@ SECTIONS
*(.text.unlikely .text.unlikely.*)
*(.text.startup .text.startup.*)
*(.text .text.* .opd .opd.*)
+ *(__lcxx_override)
*(.gnu.linkonce.t.*)
KEEP (*(.fini .fini.*))
@PREFIX@__text_end = .;

0 comments on commit e81d36c

Please sign in to comment.