User Tools

Site Tools


wswan:bugs

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
wswan:bugs [2026/01/10 20:50] – [Bug: Miscompilations involving far function pointers] asiewswan:bugs [2026/11/07 22:04] (current) – asie
Line 1: Line 1:
-====== Known issues ======+====== Known bugs and limitations ======
  
-===== gcc-ia16 =====+===== C compiler (gcc-ia16) =====
  
   * In general, if you run into a compiler error or miscompilation, try annotating the function with ''%%__attribute__((noinline, optimize("-O0"))) %%'' as a workaround.   * In general, if you run into a compiler error or miscompilation, try annotating the function with ''%%__attribute__((noinline, optimize("-O0"))) %%'' as a workaround.
   * gcc-ia16's handling of far pointers is considered experimental. Caveat emptor.   * gcc-ia16's handling of far pointers is considered experimental. Caveat emptor.
-  * gcc-ia16's handling of DS != SS (wwitch target) is pretty buggy. It works for simple code, but complex pointer operations may lead to bugs. Again, caveat emptor.+  * gcc-ia16's handling of DS != SS (wwitch target) is considered experimental. It does work for simple code, but complex pointer operations may lead to bugs. As above, caveat emptor.
   * The optimization levels ''%%-O0%%'', ''%%-O2%%'' and ''%%-Os%%'' are most stable (roughly in that order).   * The optimization levels ''%%-O0%%'', ''%%-O2%%'' and ''%%-Os%%'' are most stable (roughly in that order).
  
-==== Bug: Miscompilations involving far function pointers ====+==== Miscompilations involving far function pointers ====
  
 In some cases, when calling pointers from arrays of far function pointers in optimization modes >= -O1, the code will be miscompiled. This is a [[https://codeberg.org/tkchia/gcc-ia16/issues/6|known issue]], with no ETA for a fix. In some cases, when calling pointers from arrays of far function pointers in optimization modes >= -O1, the code will be miscompiled. This is a [[https://codeberg.org/tkchia/gcc-ia16/issues/6|known issue]], with no ETA for a fix.
Line 21: Line 21:
 </code> </code>
  
-==== Issue: wwitch target and interrupt handlers ====+==== Far pointers to near variables ====
  
-The wwitch target does not support relocation; as such, far functions (which interrupt handlers have to be) cannot be created in sections other than the default text section. This can be most easily achieved by building with ''-fno-function-sections'' in CFLAGS.+<code C> 
 +struct a { void __far *ptr; }; 
 +struct b { int value; }; 
 +struct b instance_b; 
 + 
 +// This doesn't work - compiler limitation 
 +const struct a var_ptr = { &instance_b }; 
 + 
 +// ... but this does 
 +const struct a var_ptr_fixed = { __builtin_ia16_static_far_cast(&instance_b) }; 
 + 
 +// This doesn't work - __builtin_ia16_static_far_cast only works on variable definitions 
 +const struct a field_ptr = { __builtin_ia16_static_far_cast(&instance_b.value) }; 
 + 
 +// ... but this does 
 +const struct a field_ptr_fixed = { &(((struct b __far *)__builtin_ia16_static_far_cast(&instance_b))->value) }; 
 +</code> 
 + 
 +==== wswan/bootfriend: defining interrupt handlers ==== 
 + 
 +The wswan/bootfriend target does not support relocation; as such, far functions (which interrupt handlers have to be) cannot be created in sections other than the default text section. This can be achieved by either: 
 + 
 +  * using ''%%__attribute__(section(".text"))%%'' on the function, 
 +  * building with ''%%-fno-function-sections%%'' in CFLAGS; however, this disables per-function garbage collection and may increase file size as a result. 
 + 
 +The wwitch target also prohibits defining far functions outside of the default text section, but this only becomes an issue if the FreyaBIOS system APIs (''%%sys_interrupt_set_hook%%'', ''%%sys_interrupt_reset_hook%%'') are not used, as those wrap regular C functions.
wswan/bugs.1768078229.txt.gz · Last modified: by asie