* size of CRCs in module versions @ 2003-04-16 0:25 David Mosberger 2003-04-16 5:43 ` Kai Germaschewski 0 siblings, 1 reply; 4+ messages in thread From: David Mosberger @ 2003-04-16 0:25 UTC (permalink / raw) To: linux-kernel What's the point of using "unsigned long" for storing module version CRCs? As far as I can see, the CRCs are 32 bits in size, so using u32 would be more appropriate (and would avoid wasting space on 64-bit platforms). --david ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: size of CRCs in module versions 2003-04-16 0:25 size of CRCs in module versions David Mosberger @ 2003-04-16 5:43 ` Kai Germaschewski 2003-04-16 6:25 ` David Mosberger 0 siblings, 1 reply; 4+ messages in thread From: Kai Germaschewski @ 2003-04-16 5:43 UTC (permalink / raw) To: davidm; +Cc: linux-kernel On Tue, 15 Apr 2003, David Mosberger wrote: > What's the point of using "unsigned long" for storing module version > CRCs? As far as I can see, the CRCs are 32 bits in size, so using u32 > would be more appropriate (and would avoid wasting space on 64-bit > platforms). You're right that 32 bits would be enough to hold the CRC. However, we do not yet know the checksum at compile time, so the trick I came up with is to use the linker to fill in the crcs afterwards, using assignment to absolute values. So while the crcs appear to be numbers to the C code, they are handled like addresses from the linker side, and things would most likely go badly wrong if the sizes aren't equal, though I have to admit I didn't try. --Kai ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: size of CRCs in module versions 2003-04-16 5:43 ` Kai Germaschewski @ 2003-04-16 6:25 ` David Mosberger 2003-04-16 15:44 ` Kai Germaschewski 0 siblings, 1 reply; 4+ messages in thread From: David Mosberger @ 2003-04-16 6:25 UTC (permalink / raw) To: Kai Germaschewski; +Cc: davidm, linux-kernel >>>>> On Wed, 16 Apr 2003 00:43:06 -0500 (CDT), Kai Germaschewski <kai@tp1.ruhr-uni-bochum.de> said: Kai> You're right that 32 bits would be enough to hold the Kai> CRC. However, we do not yet know the checksum at compile time, Kai> so the trick I came up with is to use the linker to fill in the Kai> crcs afterwards, using assignment to absolute values. So while Kai> the crcs appear to be numbers to the C code, they are handled Kai> like addresses from the linker side, and things would most Kai> likely go badly wrong if the sizes aren't equal, though I have Kai> to admit I didn't try. Yes, it's not easy (possible) to do it in C, but I suspect most 64-bit assemblers/linkers can do it. For example, on ia64, you can do: .global foo data4 foo Which will yield a DIR32LSB relocation (32-bit direct value), which is exactly what we'd need here. --david ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: size of CRCs in module versions 2003-04-16 6:25 ` David Mosberger @ 2003-04-16 15:44 ` Kai Germaschewski 0 siblings, 0 replies; 4+ messages in thread From: Kai Germaschewski @ 2003-04-16 15:44 UTC (permalink / raw) To: davidm; +Cc: linux-kernel On Tue, 15 Apr 2003, David Mosberger wrote: > >>>>> On Wed, 16 Apr 2003 00:43:06 -0500 (CDT), Kai Germaschewski <kai@tp1.ruhr-uni-bochum.de> said: > > Kai> You're right that 32 bits would be enough to hold the > Kai> CRC. However, we do not yet know the checksum at compile time, > Kai> so the trick I came up with is to use the linker to fill in the > Kai> crcs afterwards, using assignment to absolute values. So while > Kai> the crcs appear to be numbers to the C code, they are handled > Kai> like addresses from the linker side, and things would most > Kai> likely go badly wrong if the sizes aren't equal, though I have > Kai> to admit I didn't try. > > Yes, it's not easy (possible) to do it in C, but I suspect most 64-bit > assemblers/linkers can do it. For example, on ia64, you can do: > > .global foo > > data4 foo > > Which will yield a DIR32LSB relocation (32-bit direct value), which is > exactly what we'd need here. I looked at ppc64, since I have a cross-compile tool chain for that, it seems to have an appropriate relocation type (R_PPC64_UADDR32), but the obvious way of doing static const u32 __kcrctab_##sym \ __attribute__((section("__kcrctab" sec), unused)) \ = (u32) &__crc_##sym; and hoping for the compiler to generate appropriate assembler code doesn't work ("initializer element is not computable at load time"), so we'd need to code this in asm explicitly, which I'd rather avoid at this time. --Kai ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-04-16 15:32 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2003-04-16 0:25 size of CRCs in module versions David Mosberger 2003-04-16 5:43 ` Kai Germaschewski 2003-04-16 6:25 ` David Mosberger 2003-04-16 15:44 ` Kai Germaschewski
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®