From c6afdff7ab4dfd338a30f6aab3288e3a2d6274de Mon Sep 17 00:00:00 2001 From: herman ten brugge Date: Fri, 27 Dec 2024 09:19:03 +0100 Subject: [PATCH] Aligb section at end in tcc_load_object_file Noticed this when the crt1.o file on an updated riscv had a text section where the size is not multiple of align. This file is loaded first and when the c code is then compiled the code is not aligned any more. This results in: alignment of code section not multiple of 4 in riscv64-gen.c --- tccelf.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tccelf.c b/tccelf.c index 718d4906..2ac52b1d 100644 --- a/tccelf.c +++ b/tccelf.c @@ -3245,6 +3245,11 @@ invalid: } else { s->data_offset += size; } + /* align end of section */ + /* This is needed if we compile a c file after this */ + if (s == text_section || s == data_section || s == rodata_section || + s == bss_section || s == common_section) + s->data_offset += -s->data_offset & (s->sh_addralign - 1); next: ; }