const int x = 0; /* no problem */
const int* p = &x; /* needs address fixup - can't be used in PIC */
char *list1[] = {"zero", "one", "two"}; /* pointers need fixup */
char list2[3][5] = {"zero", "one", "two"}; /* OK, no problem */
FT2 uses lots a lot of such constants, such as arrays of pointers to
structs and function tables. This is pervasive throughout all parts of FT2.
The Changes
-----------
I propose adding an FT_CONFIG_OPTION_PIC switch that if defined, will
allow FT2 to compile to PIC:
* The previously global const structures will now be part of some
internal structure. For example inside FT_LibraryRec_ (there are other
options).
* Additional init functions will be called at library init (during
FT_Init_FreeType) that will generate the structures, arrays, tables, and
pointers at run time.
* Ideally, each structure/table/array/whatever only needs to be written
once (via a macro?), and depending on FT_CONFIG_OPTION_PIC either a
global const is generated, or a struct member with a matching init
function to be called.
* From what I could see, most parts of FT2 use such global constants.
* Ideally, the internal FT2 API would not be modified.
* We only use a subset (around 25% maybe?) of FT2.