freebsd-src icon indicating copy to clipboard operation
freebsd-src copied to clipboard

Fix declaration of unmapped_buf

Open sebhub opened this issue 2 years ago • 5 comments

For architectures with a small-data area, the __read_mostly section must present at the object declaration.

sebhub avatar Jul 19 '22 18:07 sebhub

CC @mjguzik

emaste avatar Jul 19 '22 19:07 emaste

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.

mjguzik avatar Jul 19 '22 19:07 mjguzik

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.

sebhub avatar Jul 20 '22 07:07 sebhub

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.

sebhub avatar Aug 11 '22 11:08 sebhub

@mjguzik even if this is unlikely to be an issue in practice on FreeBSD targets the declaration and definition should still match, yeah?

emaste avatar Aug 11 '22 19:08 emaste

Merged

emaste avatar Aug 16 '22 19:08 emaste