Bug 9242 - Relocate segments in native binaries when restoring from sstate
Summary: Relocate segments in native binaries when restoring from sstate
Status: NEW
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: core (show other bugs)
Version: 2.0
Hardware: All Multiple
: Medium enhancement
Target Milestone: Future
Assignee: Unassigned
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks: 9883
  Show dependency tree
 
Reported: 2016-03-11 14:31 UTC by Ross Burton
Modified: 2026-07-23 15:21 UTC (History)
6 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ross Burton 2016-03-11 14:31:13 UTC
We do magic relocation of certain libraries and binaries for nativesdk by marking certain strings with a magic segment (.gccrelocprefix) and changing that path during sdk relocation.

We should look at doing the same for native binaries from sstate. This would massively reduce the need for wrapper binaries in the sysroot, and fix situations where commonly used libraries have paths embedded in them (such as glib with GIO_MODULE_PATH).
Comment 1 Juro Bystricky 2016-03-14 17:55:37 UTC
similar problem with hard-coded paths in glibc:
https://bugzilla.yoctoproject.org/show_bug.cgi?id=8583
Comment 2 Ross Burton 2019-04-08 16:25:33 UTC
A list of recipes which could do with this:
- glib GIO module path
- curl ca-certificate path
- libxml2 catalog path
Comment 3 Jussi Kukkonen 2019-04-09 07:55:01 UTC
(In reply to comment #2)
> A list of recipes which could do with this:
> - glib GIO module path
> - curl ca-certificate path
> - libxml2 catalog path

Thanks. I'll have a go at this (self-assigning for now ).  

I had a look yesterday and below is my understanding of the tasks (do correct if I'm mistaken).


1. Add magic attribute to path variables in native binaries where needed
I guess this means patches like the glibc one:
+ static char default_gconv_path[4096] __attribute__ ((section (".gccrelocprefix"))) = GCONV_PATH;


2. Store the original sysroot path somewhere when populating the sysroot
I don't see (good) ways around this: in the SDK relocation case it's done when the SDK is generated: ##DEFAULT_INSTALL_DIR## is replaced in the relocation script itself. 
Not sure how this should be done...


3. During recipe sysroot preparation modify binaries to replace original path with current sysroot path (like relocate_sdk.py)
This should be straight forward once #2 is solved -- but would be good to not copy-paste half of relocate_sdk.py somewhere else...
Comment 4 Jussi Kukkonen 2019-04-10 11:01:21 UTC
After a bit of testing I have questions:

* the binaries in recipe-sysroot-native are hardlinks (with copies in other recipe-sysroot-natives, sysroot-components and  the original sysroot-destdir). I'm not sure what I should be doing with that -- I think the the value of e.g. CURL_CA_BUNDLE should be different for every recipe-sysroot-native dir, or is there some alternative that I've overlooked?

* Assuming I figure that out, where exactly should the binary-relocation happen? staging.bbclass::extend_recipe_sysroot() is ... scary.
Comment 5 Ross Burton 2019-04-10 12:58:23 UTC
1) Maybe unhardlink any files that get modified.  There won't be that many.

2) Talk to RP.  Yes, it is. :)