libhtc_ril.so and segfaults


If you try to get a new Android version, in this case CyanogenMod9, working on your old phone you have to deal with binary blobs. One of these blobs is the library talking to the radio, libhtc_ril.so. I wanted to document what I learned about libhtc_ril.so. I've wanted to get the library version matching my baseband version working with cm9. This resulted it several segfaults. So I've started to strace the rild process to find what's going wrong, which permissions are missing etc. The library doesn't check return values so it segfaults. One of these segfaults was a missing kernel interface called usb_function_switch. The file should be in /sys/devices/platform/msm_hsusb/usb_function_switch. I've implemented that function in the kernel and it still segfaulted…