[LLVMdev] How to prevent LLVM from emitting R_X86_64_32 ELF relocations?

Kaylor, Andrew andrew.kaylor at intel.com
Mon Apr 29 16:54:19 PDT 2013


Have you looked at the RuntimeDyld object?  It does what you're talking about.

There are definitely some issues related to reading the debug information of objects loaded into memory this way, but they can be handled without suppressing that relocation type.  Generally, you need the code that reads the debug information to behave as if all debug sections are at address zero.

Take a look at the DWARFContextInMemory class (in lib/DebugInfo) and see if it does what you need.  Even if it doesn't, you can use its handling of in-memory sections as a guide for what you need.

-Andy

-----Original Message-----
From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of Yuri
Sent: Monday, April 29, 2013 4:40 PM
To: Keith Walker
Cc: LLVM Developers Mailing List
Subject: Re: [LLVMdev] How to prevent LLVM from emitting R_X86_64_32 ELF relocations?

On 04/29/2013 15:53, Keith Walker wrote:
> It sounds like you are trying to load the DWARF sections into target memory .... and if so I guess I would have to ask you why as they are not normally loaded into target memory?

You are right, debug sections aren't normally loaded into the memory together with the sections needed for running.

However, I am mostly focusing on the (lightweight) ELF injection of the relocable ELF objects (ET_REL), and loading them into the memory as a whole, bypassing file, is often the easiest way of working with them. 
When debug info is needed, it has to be loaded into memory by debugging tools anyway. And it has to be relocated, so debugging tools have then to make sure they are placed into the lowest 4G portion for DWARF-32 debug info. So having DWARF-32 either forces abandoning the simple monolithic mount of the ELF at arbitrary address, and treating debug info separately, or just placing the whole ELF into the lowest 4G.

So, in case when it is preferable to load the whole ELF together monolithically, R_X86_64_32 entries stand in the way. I am not sure why llvm has to use DWARF-32 by default on x86_64 architectures.

Yuri
_______________________________________________
LLVM Developers mailing list
LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list