Skip to content
Snippets Groups Projects
  • Sandra Loosemore's avatar
    cc9cac9f
    libgcc, nios2: Fix exception handling on nios2 with -fpic · cc9cac9f
    Sandra Loosemore authored
    Exception handling on nios2-linux-gnu with -fpic has been broken since
    revision 790854ea, "Use _dl_find_object
    in _Unwind_Find_FDE".  For whatever reason, this doesn't work on nios2.
    
    Nios2 uses the GOT address as the base for DW_EH_PE_datarel
    relocations in PIC; see my previous fix to make this work, revision
    2d33dcfe, "Support for GOT-relative
    DW_EH_PE_datarel encoding".  So this may be a horrible bug in the ABI
    or in my interpretation of it or just glibc's implementation of
    _dl_find_object for this target, but there's existing code out there
    that does things this way; and realistically, nobody is going to
    re-engineer this now that the vendor has EOL'ed the nios2
    architecture.  So, just skip over the code trying to use
    _dl_find_object on this target and fall back to the way that works.
    
    I plan to backport this patch to the GCC 12 and GCC 13 branches as well.
    
    libgcc/ChangeLog
    	* unwind-dw2-fde-dip.c (_Unwind_Find_FDE): Do not try to use
    	_dl_find_object on nios2; it doesn't work.
    cc9cac9f
    History
    libgcc, nios2: Fix exception handling on nios2 with -fpic
    Sandra Loosemore authored
    Exception handling on nios2-linux-gnu with -fpic has been broken since
    revision 790854ea, "Use _dl_find_object
    in _Unwind_Find_FDE".  For whatever reason, this doesn't work on nios2.
    
    Nios2 uses the GOT address as the base for DW_EH_PE_datarel
    relocations in PIC; see my previous fix to make this work, revision
    2d33dcfe, "Support for GOT-relative
    DW_EH_PE_datarel encoding".  So this may be a horrible bug in the ABI
    or in my interpretation of it or just glibc's implementation of
    _dl_find_object for this target, but there's existing code out there
    that does things this way; and realistically, nobody is going to
    re-engineer this now that the vendor has EOL'ed the nios2
    architecture.  So, just skip over the code trying to use
    _dl_find_object on this target and fall back to the way that works.
    
    I plan to backport this patch to the GCC 12 and GCC 13 branches as well.
    
    libgcc/ChangeLog
    	* unwind-dw2-fde-dip.c (_Unwind_Find_FDE): Do not try to use
    	_dl_find_object on nios2; it doesn't work.