jlaitine opened a new pull request, #19116:
URL: https://github.com/apache/nuttx/pull/19116

   ## Summary
   
   Correct build errors when CONFIG_ENABLE_ALL_SIGNALS is not defined
   
   The current master doesn't compile for CONFIG_BUILD_PROTECTED with the 
following setup:
   
   ```
   #
   # Signal Configuration
   #
   # CONFIG_ENABLE_ALL_SIGNALS is not set
   CONFIG_ENABLE_PARTIAL_SIGNALS=y
   # CONFIG_DISABLE_ALL_SIGNALS is not set
   ```
   
   The first errors occur from the svcall:
   
   ```
   In file included from armv7-m/arm_svcall.c:32:
   armv7-m/arm_svcall.c: In function 'arm_svcall':
   armv7-m/arm_svcall.c:250:32: error: 'struct xcptcontext' has no member named 
'sigreturn'
     250 |           DEBUGASSERT(rtcb->xcp.sigreturn == 0);
         |                                ^
   armv7-m/arm_svcall.c:251:20: error: 'struct xcptcontext' has no member named 
'sigreturn'
     251 |           rtcb->xcp.sigreturn  = regs[REG_PC];
         |                    ^
   armv7-m/arm_svcall.c:257:53: error: 'struct userspace_s' has no member named 
'signal_handler'
     257 |           regs[REG_PC]         = (uint32_t)USERSPACE->signal_handler 
& ~1;
         |                                                     ^~
   armv7-m/arm_svcall.c:292:32: error: 'struct xcptcontext' has no member named 
'sigreturn'
     292 |           DEBUGASSERT(rtcb->xcp.sigreturn != 0);
         |                                ^
   armv7-m/arm_svcall.c:294:43: error: 'struct xcptcontext' has no member named 
'sigreturn'
     294 |           regs[REG_PC]         = rtcb->xcp.sigreturn & ~1;
         |                                           ^
   armv7-m/arm_svcall.c:300:20: error: 'struct xcptcontext' has no member named 
'sigreturn'
     300 |           rtcb->xcp.sigreturn  = 0;
         |                    ^
   make[1]: *** [Makefile:179: arm_svcall.o] Error 1
   ```
   
   Fixing that, leads to linker errors with undefined symbols with 
"nxsig_unmask_pendingsignal" etc.
   
   There are reasons why it compiles for CONFIG_BUILD_FLAT (partially by luck, 
perhaps partially by design):
   - Some of the offending code is behind CONFIG_LIB_SYSCALL, which is defined 
only in memory protected builds
   - Some of the offending code is behind CONFIG_BUILD_PROTECTED in signal 
handler
   - When the nuttx is compiled first into archives and later linked together, 
the call to nxsig_unmask_pendingsignal is only pulled in in case user calls 
ppoll, pselect, sigsuspend or such from the code (signal.o is not used in 
linking)
   
   In order to fix this cleanly, we should do the following, IMHO:
   
   - nxsig_unmask_pendingsignal is already flagged out, so also callers need to 
flag it out
   - SIGCONT is not supported with partial signals, needs to be flagged out 
also in sched_suspend
   
   I walked this through on armv7-m, and the copied the fixes directly to other 
platforms as well.
   
   ## Impact
   
   No impact on any of the current boards; the ENABLE_FULL_SIGNALS is enabled 
on !DEFAULT_SMALL, and for all the DEFAULT_SMALL boards currently in mainline, 
the full signals is enabled by default.
   
   ## Testing
   
   Tested the compilation and partial signals using a custom application, with 
the partial signal configuration, with protected and flat builds. With the 
fixes, the code builds and runs properly. Without the fix, the build and link 
errors mentioned in the description, occur on protected build.
   
   I am currently not able to test the other architectures than armv7-m, arch64 
and risc-v. Other ones are only reviewed.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to