Skip to content

Commit 0d44b28

Browse files
reznikmmJeremyGrosser
authored andcommitted
Avoid name clash when using with RP Runtimes
RP Runtimes provide some symbols with the same `External_Name` as `rp2040_hal`. So, to avoid "multiple definition" linker error we preppend a prefix when setting `use_startup=false`.
1 parent 85e2916 commit 0d44b28

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

src/drivers/rp-rom-floating_point.ads

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,35 @@ is
99
procedure Initialize
1010
with Export,
1111
Convention => C,
12-
External_Name => "__gnat_initialize_bootrom";
12+
External_Name => External_Name_Prefix & "__gnat_initialize_bootrom";
1313
-- __gnat_initialize_bootrom must be called before any of the __aeabi
1414
-- functions, which means it needs to be called before elaboration.
1515
-- crt0.S takes care of this, unless Use_Startup=false.
1616

1717
-- Run-time ABI for the Arm® Architecture
1818
-- https://github.com/ARM-software/abi-aa/blob/main/rtabi32/rtabi32.rst
1919
function fadd (A, B : Float) return Float
20-
with Export, Convention => C, External_Name => "__aeabi_fadd";
20+
with Export,
21+
Convention => C,
22+
External_Name => External_Name_Prefix & "__aeabi_fadd";
23+
2124
function fsub (A, B : Float) return Float
22-
with Export, Convention => C, External_Name => "__aeabi_fsub";
25+
with Export,
26+
Convention => C,
27+
External_Name => External_Name_Prefix & "__aeabi_fsub";
28+
2329
function frsub (A, B : Float) return Float
2430
with Export, Convention => C, External_Name => "__aeabi_frsub";
31+
2532
function fmul (A, B : Float) return Float
26-
with Export, Convention => C, External_Name => "__aeabi_fmul";
33+
with Export,
34+
Convention => C,
35+
External_Name => External_Name_Prefix & "__aeabi_fmul";
36+
2737
function fdiv (A, B : Float) return Float
28-
with Export, Convention => C, External_Name => "__aeabi_fdiv";
38+
with Export,
39+
Convention => C,
40+
External_Name => External_Name_Prefix & "__aeabi_fdiv";
2941

3042
-- __aeabi_cfcmpeq
3143
-- __aeabi_cfrcmple

src/drivers/rp-rom.ads

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
--
66
with Interfaces.C; use Interfaces.C;
77
with Interfaces; use Interfaces;
8+
with Rp2040_Hal_Config;
89
with System;
910

1011
package RP.ROM
@@ -47,12 +48,18 @@ is
4748
Code : Table_Code)
4849
return System.Address;
4950

51+
External_Name_Prefix : constant String :=
52+
(if Rp2040_Hal_Config.Use_Startup then "" else "RP_");
53+
-- This prefix is prepend to external names to avoid name clash with
54+
-- symbols in Ada runtimes (light_tasking_rp2040, etc) when setting
55+
-- use_startup = false.
56+
5057
function ROM_Func_Lookup
5158
(Code : Table_Code)
5259
return System.Address
5360
with Export,
5461
Convention => C,
55-
External_Name => "__gnat_rom_func_lookup";
62+
External_Name => External_Name_Prefix & "__gnat_rom_func_lookup";
5663

5764
function ROM_Data_Lookup
5865
(Code : Table_Code)

0 commit comments

Comments
 (0)