You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "bestvvstar (via GitHub)" <gi...@apache.org> on 2023/08/23 13:22:18 UTC
[GitHub] [nuttx] bestvvstar opened a new pull request, #10382: nuttx/boards:init_array.* needs to be executed in order
bestvvstar opened a new pull request, #10382:
URL: https://github.com/apache/nuttx/pull/10382
## Summary
nuttx/boards:init_array.* needs to be executed in order and before init_array.
## Impact
## Testing
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] xiaoxiang781216 commented on pull request #10382: nuttx/boards:init_array.* needs to be executed in order
Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on PR #10382:
URL: https://github.com/apache/nuttx/pull/10382#issuecomment-1691377051
> 1. 2 entries seem redundant.
Do you mean init_array and init_array.*?
init_array could be removed.
> 2. SORT breaks priority. Set by priority or link order. ( When the SORT keyword is used, the linker will sort the files or sections into ascending order by name before placing them in the output file.)
No, the patch fixes the priority issue instead, here is the output from gcc -Wl,-verbose:
```
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
PROVIDE_HIDDEN (__init_array_end = .);
}
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
PROVIDE_HIDDEN (__fini_array_end = .);
}
```
you can see the stock linker script add SORT_BY_INIT_PRIORITY. @cuiziweizw please change SORT to SORT_BY_INIT_PRIORITY.
> 3. If it is not referenced why keep it at all?
>
since nobody reference symbols in init_array section, the linker will remove all entries and related code from final image without KEEP. You can see the stock linker script contain KEEP too.
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] davids5 commented on pull request #10382: nuttx/boards:init_array.* needs to be executed in order
Posted by "davids5 (via GitHub)" <gi...@apache.org>.
davids5 commented on PR #10382:
URL: https://github.com/apache/nuttx/pull/10382#issuecomment-1691421342
> > 1. 2 entries seem redundant.
>
> Do you mean init_array and init_array.*? init_array could be removed.
>
> > 2. SORT breaks priority. Set by priority or link order. ( When the SORT keyword is used, the linker will sort the files or sections into ascending order by name before placing them in the output file.)
>
> No, the patch fixes the priority issue instead, here is the output from gcc -Wl,-verbose:
>
> ```
> .init_array :
> {
> PROVIDE_HIDDEN (__init_array_start = .);
> KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
> KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
> PROVIDE_HIDDEN (__init_array_end = .);
> }
> .fini_array :
> {
> PROVIDE_HIDDEN (__fini_array_start = .);
> KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
> KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
> PROVIDE_HIDDEN (__fini_array_end = .);
> }
> ```
>
> you can see the stock linker script add SORT_BY_INIT_PRIORITY. @cuiziweizw please change SORT to SORT_BY_INIT_PRIORITY.
>
> > 3. If it is not referenced why keep it at all?
>
> since nobody reference symbols in init_array section, the linker will remove all entries and related code from final image without KEEP. You can see the stock linker script contain KEEP too.
@xiaoxiang781216 Thank you for digging into the details here.
Is SORT_BY_INIT_PRIORITY portable? What is the default?
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] xiaoxiang781216 commented on pull request #10382: nuttx/boards:init_array.* needs to be executed in order
Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on PR #10382:
URL: https://github.com/apache/nuttx/pull/10382#issuecomment-1694725059
@davids5 please review again.
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] davids5 commented on pull request #10382: nuttx/boards:init_array.* needs to be executed in order
Posted by "davids5 (via GitHub)" <gi...@apache.org>.
davids5 commented on PR #10382:
URL: https://github.com/apache/nuttx/pull/10382#issuecomment-1692044585
> > @xiaoxiang781216 Thank you for digging into the details here.
> > Is SORT_BY_INIT_PRIORITY portable? What is the default?
>
> Here has detailed explanation: https://sourceware.org/binutils/docs-2.23.1/ld/Input-Section-Wildcards.html
Did it bother you that `SORT is an alias for SORT_BY_NAME.` and you got the output you did?
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] xiaoxiang781216 commented on pull request #10382: nuttx/boards:init_array.* needs to be executed in order
Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on PR #10382:
URL: https://github.com/apache/nuttx/pull/10382#issuecomment-1696241271
@bestvvstar please fix the conflict
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] xiaoxiang781216 commented on pull request #10382: nuttx/boards:init_array.* needs to be executed in order
Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on PR #10382:
URL: https://github.com/apache/nuttx/pull/10382#issuecomment-1692117092
> > > @xiaoxiang781216 Thank you for digging into the details here.
> > > Is SORT_BY_INIT_PRIORITY portable? What is the default?
> >
> >
> > Here has detailed explanation: https://sourceware.org/binutils/docs-2.23.1/ld/Input-Section-Wildcards.html
>
> Did it bother you that `SORT is an alias for SORT_BY_NAME.` and you got the output you did?
Since we just use the simple index(e.g.,100, 101...), it's same either with SORT_BY_INIT_PRIORITY or SORT_BY_NAME(SORT). But, if you use the index with different length(e.g., 1, 10, 101...), the result may different. I would suggest that it's better to follow the suggestion by document to avoid wasting the time to debug the subtle error.
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] xiaoxiang781216 commented on pull request #10382: nuttx/boards:init_array.* needs to be executed in order
Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on PR #10382:
URL: https://github.com/apache/nuttx/pull/10382#issuecomment-1691946781
> @xiaoxiang781216 Thank you for digging into the details here.
>
> Is SORT_BY_INIT_PRIORITY portable? What is the default?
Here has detailed explanation:
https://sourceware.org/binutils/docs-2.23.1/ld/Input-Section-Wildcards.html
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] acassis commented on pull request #10382: nuttx/boards:init_array.* needs to be executed in order
Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis commented on PR #10382:
URL: https://github.com/apache/nuttx/pull/10382#issuecomment-1689979854
Hi @bestvvstar please supply more information in the commit log, what was the issue this PR is fixing? What was happening when the order wasn't respected?
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] xiaoxiang781216 commented on pull request #10382: nuttx/boards:init_array.* needs to be executed in order
Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on PR #10382:
URL: https://github.com/apache/nuttx/pull/10382#issuecomment-1691162120
> Hi @bestvvstar please supply more information in the commit log, what was the issue this PR is fixing? What was happening when the order wasn't respected?
__attribute__((init_priority(X))) may stop work:
https://stackoverflow.com/questions/3371968/attribute-init-priorityx-in-gcc
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] xiaoxiang781216 merged pull request #10382: nuttx/boards:init_array.* needs to be executed in order
Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 merged PR #10382:
URL: https://github.com/apache/nuttx/pull/10382
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org