Handle GOT sections gracefully #3065
Labels
No labels
bazel
bluetooth
board settings
boot_stage2
bug
build
c++
can't reproduce
clang
clib-interface
cmsis
code cleanliness
code size
compiler version issues
cyw43_driver
debug
discussion
documentation
duplicate
dynamic_clock
elf2uf2
enhancement
errata
filesystem
flash layout
floating point
FreeRTOS
hardware_adc
hardware_claim
hardware_clocks
hardware_dma
hardware_exception
hardware_flash
hardware_gpio
hardware_i2c
hardware_irq
hardware_pio
hardware_pwm
hardware_rcp
hardware_rtc
hardware_spi
hardware_sync
hardware_uart
hardware_vreg
hardware_watchdog
hardware_xosc
help wanted
host
IAR
installation
invalid
linker scripts
lto
lwip
mbedtls
missing API
needs reporter detail
networking
newlib
newlib-multicore
non-c
non-cmake
non-gcc
openocd
orphan PR
OS integration
pico_async_context
pico_base
pico_binary_info
pico_flash
picolibc
pico_lwip
pico_malloc
pico_multicore
pico_printf
pico_runtime
pico_stdio
pico_stdio_usb
pico_sync
pico_time
pico_util
pioasm
port
question
review
review2
rtos interop
runtime init
static library
svd
test
tinyusb
vscode
wifi integration
wontfix
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-raspberrypi/pico-sdk!3065
Loading…
Reference in a new issue
No description provided.
Delete branch "got_section_handling"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
If any of the libraries linked against is built as position independent code, weak undefined symbols and comdat symbols may have GOT relocations. We observed this in the LLVM runtime libraries (libc.a/libm.a) but this behavior is not specific to Clang/LLVM toolchains. Including the GOT sections into the data section to handle them gracefully.
Fixes https://github.com/raspberrypi/pico-sdk/issues/3064
CC: @petrhosek
Also tested the gcc build on device. These were the tests I built and ran. Posting the build command for reference
@ -30,6 +30,10 @@ SECTIONS*(.data*)@ -30,6 +30,10 @@ SECTIONS*(.data*)note, i'm not sure this is the right solution - discussion in #3064
Noting this is read-write (pulled into
.data) -- is the GOT actually being updated at runtime?.rodataso we don't allocate RAM for it?Based on reading the upstream LLVM threads, it sounds like a GOT indirection is conservatively emitted, but then the relocation on the GOT entry itself is resolved statically during final link. Is that correct?
note, i think we should still fix this with read-only data probably, but i wonder if these GOT sections are related to tls, and would be fixed via
-ftls-model=local-execanwyay (which we should also add)note peter's claude analysis elsewhere was concerned about .got stuff being in flash when code is in RAM for flash only code... this is a possible wrinkle, but arguably no worse than jump tables (but it would be nice to know where the .got stuff is coming from)
might be a vote for leaving in RAM for now depending
Meaning #3112? It feels like you can end up with either orientation of code/GOT in RAM/flash so you have that problem either way.
I looked through the relevant
libc.aandlibm.afor the https://github.com/arm/arm-toolchain/releases/tag/release-22.1.0-ATfE release that Peter mentioned. Disassembled with relocations, I don't see anyR_ARM_GOT*relocations. Am I looking in the wrong place?Fixes #3112 and the sections seem to only be a few bytes, so they're fine in RAM