Hello,

I recently pushed a commit (e4d874d88a2ef874a9c2fd7c47d3d3a35ae986e2) that 
fixes code being placed in ELF sections that do not have the executable bit 
set. This happens when a function is annotated with 
__attribute__((section(".some_section"))), or when a section is defined via 
inline assembly. In the latter case, it is assumed that the inline assembly 
actually contains code, which will not always be the case, but should be the 
case the vast majority of the time. When the instruction pointer points to code 
in a non-executable section, a segmentation fault occurs.

I have included two files that recreate both of these bugs in 
tests/exec_section_in_c.c and tests/exec_section_in_asm.c. The patch is 
included on this email.

If anybody has any feedback, I would be curious to know if the blind addition 
of the executable flag to sections defined in assembly will be a problem: 
particularly if there is widespread usage of the writeable flag for these, 
which might elicit segmentation faults from the combined use of the writeable 
and executable flags for the same page.

Cheers,

- Jonathan M. Wilbur
_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to