Skip to content

Commit c6afdff

Browse files
committed
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
1 parent 90ae383 commit c6afdff

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Diff for: tccelf.c

+5
Original file line numberDiff line numberDiff line change
@@ -3245,6 +3245,11 @@ ST_FUNC int tcc_load_object_file(TCCState *s1,
32453245
} else {
32463246
s->data_offset += size;
32473247
}
3248+
/* align end of section */
3249+
/* This is needed if we compile a c file after this */
3250+
if (s == text_section || s == data_section || s == rodata_section ||
3251+
s == bss_section || s == common_section)
3252+
s->data_offset += -s->data_offset & (s->sh_addralign - 1);
32483253
next: ;
32493254
}
32503255

0 commit comments

Comments
 (0)