Re: wip/szyszka

RVP <[email protected]> Thu, 1 Jun 2023 09:53:21 +0000 (UTC)
Newsgroups gmane.os.netbsd.devel.x11
Message-ID <[email protected]>
On Wed, 31 May 2023, pin wrote:

> AFK for 2 days but I've sent you the ldd output on another e-mail addressed to you only.
>

I've got the `readelf -Wd' output but not the `ldd' one. But, it doesn't
matter now. If adding LD_PRELOAD=/usr/pkg/lib/libEGL.so fixes things, then
it clearly isn't caused by libfreetype being loaded twice.

If you want to chase that one down, you'll have to find out which libraries
are bringing in the 2 different versions of libfreetype. This is a bit
tedious to do by hand, and NetBSD's ldd doesn't support the `-a' which
would make this easy. So, I've attached an awk script which simulates a
`ldd -a'. Usage: ldd.awk /usr/pkg/bin/szyszka

-RVP

---START---
#!/usr/bin/awk -f
#
# ldda.awk: simulate `ldd -a' on OSes which don't provide
# that ldd(1) option (eg. NetBSD's)

function addpath1(s,	i, found) {
 	found = 0
 	for (i = 0; i < NPATH; i++) {
 		if (LIBPATH[i] == s) {
 			found = 1
 			break;
 		}
 	}
 	if (!found)
 		LIBPATH[NPATH++] = s
}

function addpath(dirs,	a, i, n) {
 	n = split(dirs, a, /:/)
 	for (i = 1; i <= n; i++)
 		addpath1(a[i])
}

function err(emsg) {
 	print emsg > "/dev/stderr"
 	exit 1
}

function findlib(name,	i, j, n, cmd, found, len, libs, s) {
 	NPATH = 0				# start afresh
 	if ("LD_LIBRARY_PATH" in ENVIRON)	# add user override
 		addpath(ENVIRON["LD_LIBRARY_PATH"])
 	addpath("/lib:/usr/lib")		# default NetBSD lib. search path

 	cmd = "readelf -Wd " name
 	while ((cmd | getline line) > 0) {
 		if (line ~ /\(?(R|RUN)PATH\)? + Library (r|run)path: /) {
 			i = index(line, "[")
 			if (i == 0)
 				err(name ": Bad PATH line: " line)
 			len = length(line)
 			s = substr(line, i + 1, len - (i + 1))
 			addpath(s)
 		}
 		if (line ~ /\(?NEEDED\)? + Shared library: /) {
 			i = index(line, "[")
 			if (i == 0)
 				err(name ": Bad NEEDED line: " line)
 			len = length(line)
 			s = substr(line, i + 1, len - (i + 1))
 			libs[n++] = s
 		}
 	}
 	close(cmd)
 	if (n == 0)
 		return				# libc, or error

 	print name ":"
 	for (i = 0; i < n; i++) {
 		found = 0
 		for (j = 0; j < NPATH; j++) {
 			s = LIBPATH[j] "/" libs[i]
 			cmd = sprintf("test -e '%s'", s)
 			if (system(cmd) == 0) {
 				print "\t" s
 				OBJS[s] || OBJS[s] = 1
 				found = 1
 				break
 			}
 		}
 		if (!found)
 			print "\t" libs[i] ": not found"
 	}
 	for (s in OBJS) {
 		if (OBJS[s]++ == 1)
 			findlib(s)
 	}
}

BEGIN {
 	for (i = 1; i < ARGC; i++)
 		findlib(ARGV[i])
}
---END---