Merge ~peat-new/libhybris/+git/libhybris:load-egl-lib into ~libhybris-maintainers/libhybris/+git/libhybris:master

Proposed by Ratchanan Srirattanamet
Status: Needs review
Proposed branch: ~peat-new/libhybris/+git/libhybris:load-egl-lib
Merge into: ~libhybris-maintainers/libhybris/+git/libhybris:master
Diff against target: 17 lines (+2/-1)
1 file modified
hybris/common/mm/linker.cpp (+2/-1)
Reviewer Review Type Date Requested Status
Simon Fels Needs Fixing
Review via email: mp+313218@code.launchpad.net

Description of the change

On Fairphone 2, EGL library call dlopen() with "egl/eglsubAndroid.so". In this case, libhybris will open the file directly on that path, but the file is actually at /vendor/lib/egl/, this will fail. This commit makes linker search for library in library path if it can't open library directly, which is the behavior of Android 5.0's linker.

This is the reference of this behavior:
https://android.googlesource.com/platform/bionic/+/6971fe4ca52ebdaa85ba676a044412b01d2ef1bf

To post a comment you must log in.
Revision history for this message
Simon Fels (morphis) wrote :

One minor thing inline otherwise looks good.

review: Needs Fixing
Revision history for this message
Ratchanan Srirattanamet (peat-new) wrote :

> One minor thing inline otherwise looks good.

Really sorry for long delay. I've fixed the comment and rebased the commit to the latest master.

Unmerged commits

8f29930... by Ratchanan Srirattanamet

hybris: common: mm: search lib in library path if opening directly fails.

On some device, a binary blob call dlopen with "egl/blah.so". The
correct behavior (and current code's behavior) is to open the library
directly on that path (relative to working directory) and don't look in
library path.

But the sad truth of life is, some binary blob rely on old behavior
which will not open the library directly if the path doesn't start
with '/'. As the library is actually reside in /system/vendor/lib/egl/,
the code will work with old behavior and not new behavior.

This commit makes linker search for library in library path if it can't
open library directly, which is the behavior of Android 5.0's linker.
This will let those libraries work.

This is the reference of this behavior:
https://android.googlesource.com/platform/bionic/+/6971fe4ca52ebdaa85ba676a044412b01d2ef1bf

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/hybris/common/mm/linker.cpp b/hybris/common/mm/linker.cpp
2index cc41296..a618838 100644
3--- a/hybris/common/mm/linker.cpp
4+++ b/hybris/common/mm/linker.cpp
5@@ -1139,10 +1139,11 @@ static int open_library(const char* name, off64_t* file_offset) {
6 // If the name contains a slash, we should attempt to open it directly and not search the paths.
7 if (strchr(name, '/') != nullptr) {
8 int fd = TEMP_FAILURE_RETRY(open(name, O_RDONLY | O_CLOEXEC));
9+ //... But if it's not there, failback to search it in all other library paths
10 if (fd != -1) {
11 *file_offset = 0;
12+ return fd;
13 }
14- return fd;
15 }
16
17 // Otherwise we try LD_LIBRARY_PATH first, and fall back to the built-in well known paths.

Subscribers

People subscribed via source and target branches