berkus / mclinker

Automatically exported from code.google.com/p/mclinker
Other
0 stars 0 forks source link

Spport relocation size different from bit class #126

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
FragmentLinker::writeRelocationResult has

std::memcpy(target_addr, &pReloc.target(), m_Config.targets().bitclass()/8);

which assumes relocation size is the same as bit class.
For x86-64, relocation size can be 8 bits, 16 bits, 32bits
or 64 bits.  Relocation class has

size_t size() const;

But it isn't used.

Original issue reported on code.google.com by hjl.to...@gmail.com on 14 Feb 2013 at 1:55

GoogleCodeExporter commented 9 years ago
Bypass to Diana. She is responsible for this issue.

Original comment by LubaTang on 18 Feb 2013 at 2:36

GoogleCodeExporter commented 9 years ago
We let backend relocators handle the relocation size. 
Please check Revision a0ba2cd6021d and Revision 57ce34c6c234.

There may be three ways to implement Relocation::size
1. Add a member "size" to Relocation class. While the amount of relocations is 
quite huge and may increase the runtime memoy footprint a lot.

2. Provide virtual Relocation::size to let each backend implement its own 
relocation. Wile this will let Relocation and also RelocationFactory become 
target dependent.

3. The current solution. Let the backend relocator maintain the table of 
relocation size. For the backends having the fix relocation size only needs to 
return a constant value. And for x86-64, I add a new column into 
RelocationFunctions list for size. Please refer to X86RelocationFunctions.h. I 
gave 32 for every relocations currently. Please help to fix them.

Please let us know if you have any suggestion or if the solution is not fulfill 
the needs. Thank you.

Original comment by mysekki on 19 Feb 2013 at 7:10

GoogleCodeExporter commented 9 years ago

Original comment by mysekki on 22 Feb 2013 at 3:55