gustavonihei edited a comment on pull request #3836:
URL: https://github.com/apache/incubator-nuttx/pull/3836#issuecomment-856966398


   > I found a solution. It compiles. But I cannot test if it works
   > 
   > ```
   > .flashxip : ALIGN(4)
   >    {
   >            FILL(0xff)
   > 
   >            /* Order matters */
   > 
   >            *src/imxrt_start.o(.text)
   >            *src/imxrt_boot.o(.text)
   > ```
   
   I don't have neither of the boards for testing, but I believe this change 
will render them unbootable, since it makes the linker fail to allocate the 
output section in the expected order.
   For the `raspberrypi-pico:nshsram`, it is expected that the `__start` is 
placed on address 0x20000000, which corresponds to the beginning of the `.text` 
output section. This is the `nm` output from master branch:
   ```shell
   $ nm nuttx | grep __start                         
   20000001 T __start
   ```
   After the modification from this PR, the linker allocated the interrupt 
vector table instead at that address, pushing the `__start` symbol to an 
unexpected address:
   ```shell
   $ nm nuttx | grep __start
   200000c1 T __start
   ```
   I still haven't figured out exactly the effect of this, but it seems for 
these cases where the Linker script needs to perform the placement from 
specific object files we need to forward the linker script file to the linker:
   
   ```patch
   diff --git a/boards/arm/rp2040/raspberrypi-pico/scripts/Make.defs 
b/boards/arm/rp2040/raspberrypi-pico/scripts/Make.defs
   index 2f810badf8..5f58732ab4 100644
   --- a/boards/arm/rp2040/raspberrypi-pico/scripts/Make.defs
   +++ b/boards/arm/rp2040/raspberrypi-pico/scripts/Make.defs
   @@ -30,9 +30,9 @@ else
    endif
    
    ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
   -  ARCHSCRIPT = -T "${shell cygpath -w 
$(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}"
   +  ARCHSCRIPT = -Wl,-T,"${shell cygpath -w 
$(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}"
    else
   -  ARCHSCRIPT = -T$(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
   +  ARCHSCRIPT = -Wl,-T,$(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
    endif
    
    ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
   ```
   After this change and reverting the modification to the linker scripts the 
generated output was correct.
   


-- 
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to