From 891dfcdf3fc441a1863c43d179dc6e0e4d65836f Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Sun, 4 Nov 2012 00:40:05 +0100 Subject: Generate PLT thumb stub only when necessary Generate PLT thumb stub for an ARM PLT entry only when at least one Thumb instruction branches to that entry. Warning: To save space, this commit reuses the bit 0 of entries of got_offsets array. The GOT offset is thus saved in a 31 bit value. Make sure to divide by 2 (right shift by 1) an offset before storing it there and conversely to multiply the value by 2 (left shift by 1) before using it. --- tcc.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'tcc.h') diff --git a/tcc.h b/tcc.h index 4e88782..fd4e8da 100644 --- a/tcc.h +++ b/tcc.h @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -524,11 +525,15 @@ struct TCCState { Section **priv_sections; int nb_priv_sections; /* number of private sections */ - /* got handling */ + /* got & plt handling */ Section *got; Section *plt; - unsigned long *got_offsets; - int nb_got_offsets; + struct { + unsigned long plt_thumb_stub:1; + /* mult by 2 (or left shift by 1) before use */ + unsigned long got_offset:(sizeof(long)*CHAR_BIT-1); + } *sym_infos; + int nb_sym_infos; /* give the correspondance from symtab indexes to dynsym indexes */ int *symtab_to_dynsym; -- cgit v1.3.1