If a symbol is defined in the read only data section (shows up as an 'R' in nm output), lorder(1) doesn't see it as a defined symbol. As a result, lorder can miss dependencies. How-To-Repeat: Here is a contrived example that tries to use a read only symbol defined in libz... % cat ltest.c #include <stdio.h> extern int _dist_code; int main() { printf("_dist_code: %d\n", _dist_code); return 0; } % nm -o ltest.o ltest.o: U _dist_code ltest.o:00000000 T main ltest.o: U printf % nm -go /usr/lib/libz.a | grep dist_code /usr/lib/libz.a:deflate.o: U _dist_code /usr/lib/libz.a:trees.o:00000000 R _dist_code % lorder ltest.o /usr/lib/libz.a /usr/lib/libc.a ltest.o ltest.o /usr/lib/libz.a /usr/lib/libz.a /usr/lib/libc.a /usr/lib/libc.a /usr/lib/libz.a /usr/lib/libc.a /usr/lib/libz.a /usr/lib/libc.a /usr/lib/libz.a /usr/lib/libc.a /usr/lib/libz.a /usr/lib/libc.a /usr/lib/libz.a /usr/lib/libc.a /usr/lib/libz.a /usr/lib/libc.a /usr/lib/libz.a /usr/lib/libc.a /usr/lib/libz.a /usr/lib/libc.a /usr/lib/libz.a /usr/lib/libc.a /usr/lib/libz.a /usr/lib/libc.a /usr/lib/libz.a /usr/lib/libc.a /usr/lib/libz.a /usr/lib/libc.a /usr/lib/libz.a /usr/lib/libc.a /usr/lib/libz.a /usr/lib/libc.a /usr/lib/libz.a /usr/lib/libc.a /usr/lib/libz.a /usr/lib/libc.a /usr/lib/libz.a /usr/lib/libc.a /usr/lib/libz.a /usr/lib/libc.a ltest.o /usr/lib/libc.a /usr/lib/libz.a /usr/lib/libc.a /usr/lib/libz.a /usr/lib/libc.a /usr/lib/libz.a /usr/lib/libc.a /usr/lib/libz.a /usr/lib/libc.a /usr/lib/libz.a /usr/lib/libc.a /usr/lib/libz.a /usr/lib/libc.a Notice the missing dependency of ltest.o on libz.a. So if you use lorder | tsort to determine link order, it can fail... % gcc --nostdlib /usr/lib/libc.a `lorder ltest.o /usr/lib/libz.a |tsort -q` -o ltest ltest.o(.text+0x12): In function `main': : undefined reference to `_dist_code'
Created attachment 147350 [details] Look for 'R' symbols, too. Dust off an old bug - still an issue. Add 'R' symbols to search list.
For bugs matching the following conditions: - Status == In Progress - Assignee == "bugs@FreeBSD.org" - Last Modified Year <= 2017 Do - Set Status to "Open"
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=e1d6d6f9249d37c10a0df68024c7dacebdc7bf98 commit e1d6d6f9249d37c10a0df68024c7dacebdc7bf98 Author: Ed Maste <emaste@FreeBSD.org> AuthorDate: 2021-10-18 21:19:53 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2021-10-18 21:21:17 +0000 lorder: process read-only data symbols Previously they were skipped. lorder(1) serves no functional purpose today but we might as well address this longstanding bug while it is still in the tree. PR: 133860 MFC after: 1 week Submitted by: John Hein usr.bin/lorder/lorder.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=7a789031139eef4626f7d751a2d24a58d1693c98 commit 7a789031139eef4626f7d751a2d24a58d1693c98 Author: Ed Maste <emaste@FreeBSD.org> AuthorDate: 2021-10-18 21:19:53 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2021-10-25 00:37:05 +0000 lorder: process read-only data symbols Previously they were skipped. lorder(1) serves no functional purpose today but we might as well address this longstanding bug while it is still in the tree. PR: 133860 MFC after: 1 week Submitted by: John Hein (cherry picked from commit e1d6d6f9249d37c10a0df68024c7dacebdc7bf98) usr.bin/lorder/lorder.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
A commit in branch stable/12 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=28a6e1beea0e179a5a52b338b8ea44a0766fd968 commit 28a6e1beea0e179a5a52b338b8ea44a0766fd968 Author: Ed Maste <emaste@FreeBSD.org> AuthorDate: 2021-10-18 21:19:53 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2021-10-25 00:37:56 +0000 lorder: process read-only data symbols Previously they were skipped. lorder(1) serves no functional purpose today but we might as well address this longstanding bug while it is still in the tree. PR: 133860 MFC after: 1 week Submitted by: John Hein (cherry picked from commit e1d6d6f9249d37c10a0df68024c7dacebdc7bf98) usr.bin/lorder/lorder.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)