Ranger Rick’s Amazing Prebind-O-Rama!

So I've been spending the last week trying to make prebinding happen in Fink. I've gone through a couple of stages in investigating things, and I've found a number of ways to do it that are inefficient, but none of them seem to be very elegant. I've got a couple of ADC support requests left, so I sent this to Apple:

The Problem:

Currently Fink is entirely un-prebound. I've been spending a couple of weeks trying to determine how to make prebinding Fink possible (given the large number of binaries to manage, and how often they are changed). I'm trying to figure out the minimum amount of work that packagers have to do to make prebinding possible, and what will be needed to be changed in the Fink tools to handle the backend. Unfortunately, prebinding on the scale that we're trying to accomplish is largely undocumented.

My first attempt at prebinding involved taking a list of dylibs from Fink and putting them in a file, and running seg_addr_table from cctools on it. Then I would have Fink set:

LD_SEG_ADDR_TABLE=/sw/fink/dists/seg_addr_table
LD_PREBIND=1
LD_PREBIND_ALLOW_OVERLAP=1

This way, anything that's already properly built twolevel will get built prebound.

Unfortunately, managing this seg_addr_table globally for all Fink users would be incredibly difficult.

My 2nd thought was locally generating the seg_addr_table, based on the installed packages. The biggest issue then is managing when segments change.

Then, in reading the documentation, it seems as if update_prebinding should handle everything for me, but in my testing it appears that is not the case. What I was hoping is:

sudo update_prebinding -root /

...would make new segments, and update everything for me. However, I tried the following, and didn't get what I expected:

sudo update_prebinding -root /
fink rebuild dlcompat (this makes a libdl.dylib that's prebound
to 0x00000000 again)
sudo update_prebinding -root /

I would have expected that this would find an empty address, and fix anything prebound against libdl to point to that new address. Instead I end up with the segment still set to 0x00000000.

So my question is, what do I need to do to fill in the missing piece of getting the right segments for update_prebinding? Are we still going to have to generate our own seg_addr_table? If so, it seems that we'd end up having to re-implement update_prebinding's mach-o prebound object-scanning, which seems a bit silly. What is the best way to go about doing this?

Share on Facebook

Comments are closed.