Closed matteodelabre closed 3 years ago
Thanks for the review!
Moved most file globals to block-level static variables.
what is this referring to?
There were some globals like qImageCtor
, FIRST_ALLOC
, touchArgs
, … that were defined with file visibility although they were only used in one specific function. I moved each of those definitions inside the relevant function.
let's give this thorough testing in the toltec upgrade
This PR is intended to make it safe to load the
librm2fb_client
library even when running on reMarkable 1. This is so that Toltec can ship all the binaries that need to access the framebuffer with a dynamic dependency on librm2fb_client, and eliminate the need to set the LD_PRELOAD environment variable when starting those binaries.In the library constructor, the
/sys/devices/soc0/machine
file is read to determine whether we’re running on rM1 or rM2, and set the ON_RM2 flag accordingly. When this flag is off, the wrapped system calls directly forward their arguments to the standard library.I also cleaned up some parts of the existing code, in particular:
Test plan:
librm2fb_client.so.1.0.0
and checked that the exported symbols did not change compared to the last version (usingarm-oe-linux-gnueabi-objdump -T librm2fb_client.so.1.0.0 | grep "DF .text"
), except for the removedmain
symbol:_ZN6QImageC1EiiNS_6FormatE
_Z7qputenvPKcRK10QByteArray
ioctl
open64
open
close
__libc_start_main
LD_PRELOAD=./librm2fb_client.so.1.0.0 xochitl
, checked that no preloading errors occurred and that no messages from the shim appeared. Checked that the display worked correctly and that the touchscreen was not inverted.LD_PRELOAD=./librm2fb_client.so.1.0.0 calculator
and performed the same checks as in the previous item.LD_PRELOAD=./librm2fb_client.so.1.0.0 xochitl
and checked that no preloading errors occurred, and that the following messages from the shim appeared:Also checked that the display worked correctly and that the touchscreen was not inverted.
LD_PRELOAD=./librm2fb_client.so.1.0.0 calculator
and checked that no preloading errors occurred, that the display worked correctly, and that the touchscreen was not inverted.