Skip to content

Commit

Permalink
Aligb section at end in tcc_load_object_file
Browse files Browse the repository at this point in the history
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
  • Loading branch information
hermantb committed Dec 27, 2024
1 parent 90ae383 commit c6afdff
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tccelf.c
Original file line number Diff line number Diff line change
Expand Up @@ -3245,6 +3245,11 @@ ST_FUNC int tcc_load_object_file(TCCState *s1,
} 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: ;
}

Expand Down

0 comments on commit c6afdff

Please sign in to comment.