Placing a global variable at a constant address

已查看 22 次
跳至第一个未读帖子

Alexandre Dang

未读,
2017年5月3日 09:47:022017/5/3
收件人 Native-Client-Discuss
Hello everyone,

I'm currently implementing my own version of SFI derived from nacl.
For that I need to have a global variable which address is
  1. known at compile time.
  2. aligned on its size (for masking purpose)

I have some ideas for that but I don't know if they are possible:

  • Use a linker script to create a new section and put my global variable in this fixed address section.
    However I use sel_ldr, so I guess I need to do this step in sel_ldr code which might be a bit complex.
  • Introduce some padding to have my section .data at a desired location.
    Section .data is preceded by the sections:
    1. .note.gnu.build-id (constant size and start at a fix address)
    2. .rodata
    3. .eh_frame (constant size?)
    4. .tdata
    5. .init_array (constant size in most cases I think)
    6. .fini_array (constant size in most cases I think)
    7. .got.plt (constant size)
    8. .data

    Hence I would put some extra data in the .tdata section to create a padding. However I don't really know the purpose of this section,
    I only know that in the disassembly it contains a variable called "impure_data".

Are my ideas possible or is there any simpler solution?


Thanks

回复全部
回复作者
转发
0 个新帖子