From e966b8b997eaecbb201339eb825be767df65b859 Mon Sep 17 00:00:00 2001 From: Julius Werner Date: Mon, 27 Apr 2020 19:05:33 -0700 Subject: 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 Change-Id: Iea93788a13e9fd14d6b5a16626294d5a4b0e5411 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2169480 Reviewed-by: Joel Kitching --- firmware/2lib/2crypto.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'firmware/2lib/2crypto.c') 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 -- cgit v1.2.1