Skip to content

native_posix: Warnings during link on orphan sections after #10368 #10493

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pfalcon opened this issue Oct 10, 2018 · 11 comments
Closed

native_posix: Warnings during link on orphan sections after #10368 #10493

pfalcon opened this issue Oct 10, 2018 · 11 comments
Assignees
Labels
area: native port Host native arch port (native_sim) bug The issue is a bug, or the PR is fixing a bug priority: high High impact/importance bug

Comments

@pfalcon
Copy link
Collaborator

pfalcon commented Oct 10, 2018

Resubmitted from #10368 (comment) :

After #10368 was applied, building for BOARD=native_posix produces warnings like below. The resulting executable seems to work.

[100%] Linking C executable zephyr.elf
/usr/bin/ld: warning: orphan section `.rel._k_mutex.static.pthread_key_lock' from `/usr/lib/gcc/x86_64-linux-gnu/7/../../../i386-linux-gnu/Scrt1.o' being placed in section `.rel.dyn'.
/usr/bin/ld: warning: orphan section `.rel._k_mem_slab.static.posix_timer_slab' from `/usr/lib/gcc/x86_64-linux-gnu/7/../../../i386-linux-gnu/Scrt1.o' being placed in section `.rel.dyn'.
/usr/bin/ld: warning: orphan section `.rel._k_sem.static.pthread_key_sem' from `/usr/lib/gcc/x86_64-linux-gnu/7/../../../i386-linux-gnu/Scrt1.o' being placed in section `.rel.dyn'.
/usr/bin/ld: warning: orphan section `.rel._k_sem.static.mq_sem' from `/usr/lib/gcc/x86_64-linux-gnu/7/../../../i386-linux-gnu/Scrt1.o' being placed in section `.rel.dyn'.
/usr/bin/ld: warning: orphan section `.rel.log_const_kernel' from `/usr/lib/gcc/x86_64-linux-gnu/7/../../../i386-linux-gnu/Scrt1.o' being placed in section `.rel.dyn'.
Generating files from zephyr.elf for board: native_posix
@pfalcon pfalcon added the area: native port Host native arch port (native_sim) label Oct 10, 2018
@pfalcon
Copy link
Collaborator Author

pfalcon commented Oct 10, 2018

cc: @aescolar

@pfalcon pfalcon added the priority: low Low impact/importance bug label Oct 10, 2018
@pfalcon pfalcon changed the title native_posix: Warnings on orphan sections after #10368 native_posix: Warnings during link on orphan sections after #10368 Oct 10, 2018
@aescolar aescolar added priority: medium Medium impact/importance bug and removed priority: low Low impact/importance bug labels Oct 11, 2018
@aescolar
Copy link
Member

aescolar commented Oct 11, 2018

Raising the priority to medium high as this breaks sanitycheck in native_posix fully for "newer" OSs default installations. (With newer, meaning newer than Ubuntu 14.04 which we use in CI). This will break the workflow for too many people who run sanitycheck locally.

@aescolar
Copy link
Member

aescolar commented Oct 11, 2018

Note, this can be reproduced with samples/hello_world in Ubuntu 18.04 with the default distro gcc (7.3)

@pfalcon
Copy link
Collaborator Author

pfalcon commented Oct 11, 2018

@aescolar: Are you hinting that this is related to PIE?

@aescolar
Copy link
Member

Are you hinting that this is related to PIE?

No.. I just pointed to a very typical Linux distribution..

@aescolar aescolar added priority: high High impact/importance bug and removed priority: medium Medium impact/importance bug labels Oct 11, 2018
@nashif nashif added the bug The issue is a bug, or the PR is fixing a bug label Oct 11, 2018
@dcpleung
Copy link
Member

GCC on Ubuntu has PIE turned on by default (since 16.10, IIRC). If you do gcc --v and there is an "--enable-default-pie", native_posix will fail to build. Adding "-no-pie" as linker option gets past the PIE issue, but it complains about not able to find "-lgcc_s" (libgcc_s.so and libgcc_s.so.1 are installed by GCC).

@aescolar Are you hitting the PIE issue? If so, we need to create another issue for that.

dcpleung added a commit to dcpleung/zephyr that referenced this issue Oct 11, 2018
There are sections defined in common-rom/ram.ld where they are
showing up as orphan sections. So add these as known sections.

Fixes zephyrproject-rtos#10493

Signed-off-by: Daniel Leung <[email protected]>
@aescolar
Copy link
Member

aescolar commented Oct 11, 2018

native_posix will fail to build

With "fail to build" you mean you will get a warning from the linker due to orphan sections?

@dcpleung
Copy link
Member

Not due to orphan sections, but something like this:

/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: ../libapp.a(main.c.obj): warning: relocation in read-only section `.text.zephyr_app_main'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: warning: creating a DT_TEXTREL in object.

This causes sanitycheck to fail.

But PR #10528 will fix the orphan section warning emitted.

nashif pushed a commit that referenced this issue Oct 11, 2018
There are sections defined in common-rom/ram.ld where they are
showing up as orphan sections. So add these as known sections.

Fixes #10493

Signed-off-by: Daniel Leung <[email protected]>
@aescolar
Copy link
Member

aescolar commented Oct 11, 2018

Still some missing (on ae8649c):

/usr/bin/x86_64-linux-gnu-ld: warning: orphan section `.rel.shell_cmd_' from `/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib32/Scrt1.o' being placed in section `.rel.dyn'.
/usr/bin/x86_64-linux-gnu-ld: warning: orphan section `.rel.shell_module_' from `/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib32/Scrt1.o' being placed in section `.rel.dyn'.
/usr/bin/x86_64-linux-gnu-ld: warning: orphan section `.rel.shell_root_cmd_hrs' from `/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib32/Scrt1.o' being placed in section `.rel.dyn'.
/usr/bin/x86_64-linux-gnu-ld: warning: orphan section `.rel.shell_root_cmd_resize' from `/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib32/Scrt1.o' being placed in section `.rel.dyn'.
/usr/bin/x86_64-linux-gnu-ld: warning: orphan section `.rel.shell_root_cmd_history' from `/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib32/Scrt1.o' being placed in section `.rel.dyn'.
/usr/bin/x86_64-linux-gnu-ld: warning: orphan section `.rel.shell_root_cmd_help' from `/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib32/Scrt1.o' being placed in section `.rel.dyn'.
/usr/bin/x86_64-linux-gnu-ld: warning: orphan section `.rel.shell_root_cmd_shell' from `/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib32/Scrt1.o' being placed in section `.rel.dyn'.
/usr/bin/x86_64-linux-gnu-ld: warning: orphan section `.rel.shell_root_cmd_clear' from `/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib32/Scrt1.o' being placed in section `.rel.dyn'.
/usr/bin/x86_64-linux-gnu-ld: warning: orphan section `.rel.shell_root_cmd_bt' from `/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib32/Scrt1.o' being placed in section `.rel.dyn'.
/usr/bin/x86_64-linux-gnu-ld: warning: orphan section `.rel.shell_root_cmd_gatt' from `/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib32/Scrt1.o' being placed in section `.rel.dyn'.
/usr/bin/x86_64-linux-gnu-ld: warning: orphan section `.rel.shell_root_cmd_l2cap' from `/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib32/Scrt1.o' being placed in section `.rel.dyn'.

20 out of 250 of sanitycheck -p native_posix would seem to be failing now due to this shell sections.

@aescolar aescolar reopened this Oct 11, 2018
@aescolar
Copy link
Member

aescolar commented Oct 11, 2018

Not due to orphan sections, but something like this:

I just did a quick trial build with and without PIE in a Ubuntu 18.04 machine and did not see neither of the problems you mention (lgcc_s or relocation in read-only section). I guess I'm missing something.

@dcpleung
Copy link
Member

Hm... I haven't seen the shell ones on my development machine. It was on GCC 6.4.0 though.

The new PR #10536 should fix the shell_* section.

dcpleung added a commit to dcpleung/zephyr that referenced this issue Oct 12, 2018
Update rel-sections.ld to use wildcards instead of
spelling out those sections one by one.

Also, for POSIX, don't include this and turns off
the warnings. With different host toolchain across
different OS, it would be maintanence nightmare
to account for all those combinations. So this reverts
the POSIX linker script to before the first orphan
section changes.

Fixes zephyrproject-rtos#10493

Signed-off-by: Daniel Leung <[email protected]>
nashif pushed a commit that referenced this issue Oct 12, 2018
Update rel-sections.ld to use wildcards instead of
spelling out those sections one by one.

Also, for POSIX, don't include this and turns off
the warnings. With different host toolchain across
different OS, it would be maintanence nightmare
to account for all those combinations. So this reverts
the POSIX linker script to before the first orphan
section changes.

Fixes #10493

Signed-off-by: Daniel Leung <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: native port Host native arch port (native_sim) bug The issue is a bug, or the PR is fixing a bug priority: high High impact/importance bug
Projects
None yet
Development

No branches or pull requests

4 participants