为什么 ARM Linux ELF 模块加载器支持这些特定的重定位?
Why are these specific relocations supported in ARM Linux ELF module loader?
我指的是 linux/arch/arm/kernel/module.c. It seems to be an arbitrary subset of ARM ELF relocations. The manual 列出的大约 130 种搬迁类型。其中大部分是 "static" (为什么模块加载器处理静态重定位而不是动态重定位?)是因为 GCC 只输出这些类型吗?还是另有原因?
ARM 手册适用于所有 ELF 文件;这包括 'C' 编译器在 linked 之前的输出。 130搬迁类型适用于多种情况;模块加载器只处理其中的一个子集。对于共享库和内核模块,最终输出不知道它的最终地址,但它知道所有 function/data 相对于彼此的位置。需要处理绝对重定位。
它不会尝试 link 将“.o”文件组合在一起以制作“.ko”。这是由 ld
完成的,它将处理更多的重定位类型,但可能仍然不是全部。 规范 旨在全球完成。目标 CPU 上可能不需要某些类型的重定位(比如一些非常老的 ARM1 26 位)。
我从 ARM Linux 新闻组得到以下答复:
http://lists.infradead.org/pipermail/linux-arm-kernel/2015-May/345809.html
Under the configuration that is used to compile the kernel, only a
small subset of those relocations will ever be emitted by GCC. For
instance, since we are building without -fpic, many of the GOT and PLT
related ones will just never occur. And, since modules are not shared
libraries, but just partially linked object files, the runtime linking
that occurs actually resembles static linking more than it resembles
dynamic linking. (There is no support for things like lazy resolution
of jump targets or symbol preemption that the ELF standard defines.)
Also, while text relocations are typically avoided in userland since
they defeat sharing of code pages, this is not a problem in the
kernel.
所以原因是因为GCC编译内核模块只会输出那些重定位。我希望 GCC ARM 维护者知道这一点...
我指的是 linux/arch/arm/kernel/module.c. It seems to be an arbitrary subset of ARM ELF relocations. The manual 列出的大约 130 种搬迁类型。其中大部分是 "static" (为什么模块加载器处理静态重定位而不是动态重定位?)是因为 GCC 只输出这些类型吗?还是另有原因?
ARM 手册适用于所有 ELF 文件;这包括 'C' 编译器在 linked 之前的输出。 130搬迁类型适用于多种情况;模块加载器只处理其中的一个子集。对于共享库和内核模块,最终输出不知道它的最终地址,但它知道所有 function/data 相对于彼此的位置。需要处理绝对重定位。
它不会尝试 link 将“.o”文件组合在一起以制作“.ko”。这是由 ld
完成的,它将处理更多的重定位类型,但可能仍然不是全部。 规范 旨在全球完成。目标 CPU 上可能不需要某些类型的重定位(比如一些非常老的 ARM1 26 位)。
我从 ARM Linux 新闻组得到以下答复: http://lists.infradead.org/pipermail/linux-arm-kernel/2015-May/345809.html
Under the configuration that is used to compile the kernel, only a small subset of those relocations will ever be emitted by GCC. For instance, since we are building without -fpic, many of the GOT and PLT related ones will just never occur. And, since modules are not shared libraries, but just partially linked object files, the runtime linking that occurs actually resembles static linking more than it resembles dynamic linking. (There is no support for things like lazy resolution of jump targets or symbol preemption that the ELF standard defines.) Also, while text relocations are typically avoided in userland since they defeat sharing of code pages, this is not a problem in the kernel.
所以原因是因为GCC编译内核模块只会输出那些重定位。我希望 GCC ARM 维护者知道这一点...