summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2020-04-27 19:05:33 -0700
committerCommit Bot <commit-bot@chromium.org>2020-04-29 00:52:50 +0000
commite966b8b997eaecbb201339eb825be767df65b859 (patch)
tree2f15f576f50f56a93926fa85b5c0f65da7ba83f7
parent3aab301473ec0b95f109a245efeadc20c3b7d57d (diff)
downloadvboot-e966b8b997eaecbb201339eb825be767df65b859.tar.gz
2crypto: Force correct section flags for .rodata arrays
This is a follow-up fix to CL:2157900. That CL put the problematic arrays into sections with the right name, but they still didn't set the right ELF flags for them (specifically the READONLY flag). This made the assembler unhappy in coreboot, although it still seems to have built things correctly in the end: {standard input}: Assembler messages: {standard input}:359: Warning: setting incorrect section attributes for .rodata.vb2_hash_names {standard input}:369: Warning: setting incorrect section attributes for .rodata.vb2_sig_names This patch throws more ugly hacks at the problem to make it disappear. BRANCH=None BUG=None TEST=Build coreboot for both Arm and x86 boards, confirmed that error messages are gone and objdump shows intended section flags. Signed-off-by: Julius Werner <jwerner@chromium.org> Change-Id: Iea93788a13e9fd14d6b5a16626294d5a4b0e5411 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2169480 Reviewed-by: Joel Kitching <kitching@chromium.org>
-rw-r--r--firmware/2lib/2crypto.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/firmware/2lib/2crypto.c b/firmware/2lib/2crypto.c
index 2b55386b..46071069 100644
--- a/firmware/2lib/2crypto.c
+++ b/firmware/2lib/2crypto.c
@@ -15,10 +15,11 @@
* These two need to be exported for host/lib/crypto.c, but they also need to be
* in .rodata to make coreboot XIP stages happy. We know they are immutable but
* there is no C language way to guarantee that, so we have to manually force
- * the compiler to place them in .rodata.
+ * the compiler to place them in .rodata. Also inject custom section flags so
+ * they are only allocatable (a) but not writeable (w).
*/
-__attribute__((section(".rodata.vb2_sig_names")))
+__attribute__((section(".rodata.vb2_sig_names,\"a\"\n# ")))
const char *vb2_sig_names[VB2_SIG_ALG_COUNT] = {
[VB2_SIG_NONE] = "none",
[VB2_SIG_RSA1024] = "RSA1024",
@@ -29,7 +30,7 @@ const char *vb2_sig_names[VB2_SIG_ALG_COUNT] = {
[VB2_SIG_RSA3072_EXP3] = "RSA3072EXP3",
};
-__attribute__((section(".rodata.vb2_hash_names")))
+__attribute__((section(".rodata.vb2_hash_names,\"a\"\n# ")))
const char *vb2_hash_names[VB2_HASH_ALG_COUNT] = {
[VB2_HASH_NONE] = "none",
#if VB2_SUPPORT_SHA1