Skip to content
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

pkg/ldd: filter dependencies without a filesystem path #2633

Merged
merged 2 commits into from
Feb 25, 2023

Conversation

florianGla
Copy link
Contributor

@florianGla florianGla commented Feb 24, 2023

Running the interpreter gives results of the following form:

linux-vdso.so.1 => linux-vdso.so.1
libc.so.6 => /usr/lib/libc.so.6
libc.so.6 => /usr/lib/libc.so.6 (0x00007ffe4972d000)
linux-vdso.so.1 => (0x00007ffe4972d000)

In the last example the file path is empty and only the memory address is shown. Those cases should be skipped because the third field is assumed to be a valid file path.

@codecov
Copy link

codecov bot commented Feb 24, 2023

Codecov Report

Base: 74.71% // Head: 74.87% // Increases project coverage by +0.16% 🎉

Coverage data is based on head (0eb7eb9) compared to base (a41bade).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2633      +/-   ##
==========================================
+ Coverage   74.71%   74.87%   +0.16%     
==========================================
  Files         412      412              
  Lines       41649    41651       +2     
==========================================
+ Hits        31117    31188      +71     
+ Misses      10532    10463      -69     
Impacted Files Coverage Δ
pkg/ldd/ldd_unix.go 80.19% <100.00%> (+0.40%) ⬆️
pkg/acpi/rsdp.go 51.28% <0.00%> (+10.25%) ⬆️
pkg/acpi/raw.go 89.28% <0.00%> (+14.28%) ⬆️
pkg/acpi/bios.go 83.78% <0.00%> (+83.78%) ⬆️
pkg/acpi/sdt.go 86.66% <0.00%> (+86.66%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@florianGla florianGla force-pushed the filter-deps branch 3 times, most recently from cd7f8b0 to 1240e79 Compare February 24, 2023 14:56
In some cases the interpreter returns dependencies without
a filesystem path, e.g.:

linux-vdso.so.1 => (0x00007ffe4972d000)

Those dependencies should be skipt.

Signed-off-by: Florian Gläßer <florian.glaesser@code-intelligence.com>
Copy link
Member

@rminnich rminnich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, first time we've seen this, what system was it on? Could you include that in the commit message?

@10000TB
Copy link
Member

10000TB commented Feb 24, 2023

last element being address is not wrong ?

linux-vdso.so.1 is a virtual shared object, automatically mapped to each process's address space. It is called by libc, not by your program directly (I think?). That is why it does not have a file in typical shared object directory /usr/lib/

@10000TB
Copy link
Member

10000TB commented Feb 24, 2023

but the print format can be improved, e.g. removing the => in such case.

It should print like linux-vdso.so.1 (0x00007ffe4972d000) ?

Here is an example on my Ubuntu

~$ ldd server
	linux-vdso.so.1 (0x00007ffd4615d000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f3516f93000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f3516eb4000)
	librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f3516eaf000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f3516eaa000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f350e41f000)
        ...

@rminnich
Copy link
Member

last element being address is not wrong ?

linux-vdso.so.1 is a virtual shared object, automatically mapped to each process's address space.

This is being printed by ld.so, not something we control. It's not wrong, but the whole point of this package is to return a list of files, and we can't return a file in that case, so it needs to be ignored.

What's odd is that the print format has changed. here is my ubuntu:
linux-vdso.so.1 (0x00007ffc3e982000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f88f803a000)

note that if there is no file, there is no =>

whatever system Florian is running on prints a => with an empty file name. That's kind of weird, but we have to accomodate it.

@rminnich
Copy link
Member

but the print format can be improved, e.g. removing the => in such case.

It should print like linux-vdso.so.1 (0x00007ffe4972d000) ?

Here is an example on my Ubuntu

~$ ldd server
	linux-vdso.so.1 (0x00007ffd4615d000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f3516f93000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f3516eb4000)
	librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f3516eaf000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f3516eaa000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f350e41f000)
        ...

we don't control that print format, right? ldd oln linux does this:
/lib64/ld-linux-x86-64.so.2 --list /bin/date
and we just get the output.

So, sure, that is what your Ubuntu does, but florian's system does something else, and we have to tolerate it.

@rminnich rminnich merged commit 5b46c23 into u-root:main Feb 25, 2023
@10000TB
Copy link
Member

10000TB commented Feb 25, 2023

]don't know what loader --list prints like previously. But I guess we now know it can change.

but I wonder what it prints like now, with this change ? @florianGla

Based on the comments, it will look like following after removing last line,

linux-vdso.so.1 => linux-vdso.so.1
libc.so.6 => /usr/lib/libc.so.6
libc.so.6 => /usr/lib/libc.so.6 (0x00007ffe4972d000)

first line does not look right, linux-vdso.so.1 => linux-vdso.so.1, kind a self self pointing. That does not look right to me. This library apparently does not have a placement directly in filesystem.

secondly, we have 2 duplicate lines

libc.so.6 => /usr/lib/libc.so.6
libc.so.6 => /usr/lib/libc.so.6 (0x00007ffe4972d000)

they have same linker name and soname (borrowing naming from https://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html).

I also wonder what is the output if we run the interpreter directly ? /lib64/ld*.so.* --list <same program>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants