从内存dlopen的? [英] dlopen from memory?

查看:1285
本文介绍了从内存dlopen的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方式来直接从内存中加载生成的对象code。

I'm looking for a way to load generated object code directly from memory.

我明白,如果我把它写入一个文件,我可以打电话的dlopen动态加载它的符号并将其链接。然而,这似乎有点迂回的方式,考虑到它在内存中开始了,被写入到磁盘,然后由dlopen在内存中加载。我不知道是否有某种方式来动态链接目标code存在于内存中。从我可以告诉可能有几种不同的方式来做到这一点:

I understand that if I write it to a file, I can call dlopen to dynamically load its symbols and link them. However, this seems a bit of a roundabout way, considering that it starts off in memory, is written to disk, and then is reloaded in memory by dlopen. I'm wondering if there is some way to dynamically link object code that exists in memory. From what I can tell there might be a few different ways to do this:


  1. 天雷的dlopen以为你的记忆位置是一个文件,即使它从来没有离开的记忆。

  1. Trick dlopen into thinking that your memory location is a file, even though it never leaves memory.

找一些其他的系统调用它做什么我要找的(我不认为这存在)。

Find some other system call which does what I'm looking for (I don't think this exists).

找一些动态链接库,可以在内存中链接code直接。很显然,这个人是有点难以谷歌,如动态链接库变成了如何动态链接库,它们不是在执行动态链接任务库的信息。

Find some dynamic linking library which can link code directly in memory. Obviously, this one is a bit hard to google for, as "dynamic linking library" turns up information on how to dynamically link libraries, not on libraries which perform the task of dynamically linking.

摘要从连接器的一些API,并创建一个新的库其codeBase的。 (显然这对我来说是最不理想的选项)。

Abstract some API from a linker and create a new library out its codebase. (obviously this is the least desirable option for me).

因此​​,这其中的有可能吗?可行?你能指出我的任何假设我存在的东西呢?有没有我还没有想过的另一种方式?

So which ones of these are possible? feasible? Could you point me to any of the things I hypothesized existed? Is there another way I haven't even thought of?

推荐答案

有是做其他的比写出来的文件,然后用的dlopen重新装入()

There is no standard way to do it other than writing out the file and then loading it again with dlopen().

您可能会发现你的当前特定平台上的一些替代方法。它将由您来决定是否比使用标准(相对)便携的方式更好。

You may find some alternative method on your current specific platform. It will up to you to decide whether that is better than using the 'standard and (relatively) portable' approach.

由于在首位生成对象code是相当具体的平台,其他特定于平台的技术可能并不重要你。但它是一个判断呼叫 - 和在任何情况下取决于是否有非标准的技术,这是比较不可能

Since generating the object code in the first place is rather platform specific, additional platform-specific techniques may not matter to you. But it is a judgement call - and in any case depends on there being a non-standard technique, which is relatively improbable.

这篇关于从内存dlopen的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆