freebsd-src
freebsd-src copied to clipboard
Fix declaration of unmapped_buf
For architectures with a small-data area, the __read_mostly section must present at the object declaration.
CC @mjguzik
I don't see how that would happen.
I have to note very few archs have linker script support for these annotations and I'm guessing this is why it's not working out for whatever arch you are looking at.
I don't use the FreeBSD kernel directly. I use a port of FreeBSD kernel code to RTEMS. I got an error on powerpc. The problem is when you don't add the __read_mostly to the declaration, then the compiler will generated small-data relocations for load/store instructions. In the definition the object is placed in the __read_mostly section and not the small-data area. If these two sections are to far away in the executable, then the linker cannot resolve the small-data relocation.
Is there a general issue with this patch? From my point of view it fixes an obvious issue for all targets with small-data area.
@mjguzik even if this is unlikely to be an issue in practice on FreeBSD targets the declaration and definition should still match, yeah?
Merged