To test the writer: $ ./test-write linearize.c export syms 29 internal 72 import 47 struct instruction * size 349524 struct entrypoint * size 2280 struct basic_block * size 39248 pseudo_t size 118632 struct pseudo_user * size 0 struct asm_constraint * size 0 struct symbol * size 358608 struct asm_rules * size 0 struct multijmp * size 1344 struct expression * size 4064 struct ident * size 12596 struct string * size 0 char * size 0 char * (stream) size 191 struct ptr_list * size 114948 toalsize 995359 It generate linearize.b file. Some internal detail: traverse.c is responsible for traverse the pointer in an object. It don't actually convert the pointer. It delegates the actual convertion to the caller. The reader and writer can share the same traverse code to convert the pointer to index, index back to pointer. The writer use a two pass stage to write the object file. The first pass is finding out which object need to write out to the file. It register them into the hash table for later look up. It add a shadow copy of the object with all the pointer inside the object converted into index. This is a recursive process until all the object under dependency has been registered. The second stage is the actual dumping of the registered file. Compare to the one step convert and dump approach (been there done that). The two step write back generate very nice sequential disk IO. It is also much easier to work with. We can optionally apply some compression method before we write it to the disk. It can save the object file size. Currently it is the raw C structure. Known limits: - static string is not saved yet. The linearizer skip the initialization part of the storage type symbol. We should consider generate some initialization node for lay out the static C structure initializer. - I think the linearized instruction does not have the full C type information yet. - A few more I can't remember right now. - Reader is half baked. Not included in this patch series. Too ugly to show on the list. Drop me a line and I can send you what I got. I will be very glad if some one want to adopt this... Comments are welcome. Chris Signed-Off-By: Christopher Li <sparse@xxxxxxxxxxx>
Attachment:
writer-5
Description: Binary data