fix(rockchip): add support for building with LTO enabled
Using the asm .incbin statement in C sources breaks gcc wrapper.
Build fails with a following errors:
/tmp/ccRXHTU4.s: Assembler messages:
/tmp/ccRXHTU4.s:34: Warning: dwarf line number information for .pmusram.incbin ignored
...
/tmp/ccRXHTU4.s:2119: Warning: dwarf line number information for .pmusram.incbin ignored
/tmp/ccRXHTU4.s:112497: Error: leb128 operand is an undefined symbol: .LVU5
/tmp/ccRXHTU4.s:112498: Error: leb128 operand is an undefined symbol: .LVU6
/tmp/ccRXHTU4.s:112507: Error: leb128 operand is an undefined symbol: .LVU9
...
/tmp/ccRXHTU4.s:115407: Error: leb128 operand is an undefined symbol: .LVU668
/tmp/ccRXHTU4.s:115408: Error: leb128 operand is an undefined symbol: .LVU710
/tmp/ccRXHTU4.s:115409: Error: leb128 operand is an undefined symbol: .LVU713
lto-wrapper: fatal error: aarch64-none-elf-gcc returned 1 exit status
compilation terminated.
aarch64-none-elf/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
Fix it in a similar way to what the Linux kernel does, see commit
919aa45e43a84d40c27c83f6117cfa6542cee14e (MODSIGN: Avoid using .incbin
in C source). [1]
1. https://lkml.org/lkml/2012/12/4/136
Change-Id: Iecc19729ce59e8c3b3c30fa37b1fddef95e83c96
Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
diff --git a/plat/rockchip/rk3399/drivers/pmu/pmu_fw.S b/plat/rockchip/rk3399/drivers/pmu/pmu_fw.S
new file mode 100644
index 0000000..26f3313
--- /dev/null
+++ b/plat/rockchip/rk3399/drivers/pmu/pmu_fw.S
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2024, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/* convoluted way to make sure that the define is pasted just the right way */
+.macro INCBIN file sym sec
+ .section \sec
+ .global \sym
+ .type \sym, @object
+ .align 4
+\sym :
+ .incbin \file
+ .size \sym , .-\sym
+ .global \sym\()_end
+\sym\()_end :
+.endm
+
+INCBIN ""RK3399M0FW"", "rk3399m0_bin", ".sram.incbin"
+INCBIN ""RK3399M0PMUFW"", "rk3399m0pmu_bin", ".pmusram.incbin"