是否按需加载/卸载ELF部分? [英] Loading/unloading ELF sections on demand?

查看:115
本文介绍了是否按需加载/卸载ELF部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于一个相当晦涩的用例,我希望有一个(大型)静态链接的Linux可执行文件,该可执行文件由一小段控制代码和一大段静态(只读)数据组成。是否可以节省内存,以使加载程序仅加载控制代码的各个部分,然后根据需要手动加载RO数据的各个部分,并在处理完成后再次将其卸载?

For a rather obscure use case I'd like to have a (large) statically linked Linux executable made up of a small piece of control code and large pieces of static (read-only) data. Is it possible, to save memory, to get the loader to load only the sections for the control code, and then manually load the sections of RO data as they are needed, and unload them again once the processing is done?

这可能吗?

(我想(文件系统级别的)数据流可以用来解决这个问题,但是它们(EXT3)不可用,并且分发会很棘手,因为数据流很容易丢失。)

(I suppose data streams (on the filesystem level) could be used to solve this, but they aren't available to me (EXT3) and distribution would be tricky since data streams easily get lost.)

推荐答案

当然,真正的答案将取决于系统,但总的来说,现代操作系统(当然还有Linux)的使用需求分页执行程序,因此实际上不会为未引用的ELF文件部分分配RAM。

The real answer of course will be system-dependent, but in general, modern operating systems (and certainly Linux) use demand paging for executables, so no RAM will be actually allocated for sections of the ELF file you don't reference.

这篇关于是否按需加载/卸载ELF部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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