Linux kernel's vdso64.so is compiled with "-Wl,-z,common-page-size=4096" which is not supported by LLD and leads to linker error: ld.lld: error: unknown -z value: common-page-size=4096 "common-page-size=value" is not a recognized keyword for LLD, but it is for GNU ld. GNU ld manpage describes this keyword as the following: common-page-size=value Set the emulation common page size to value.
*** Bug 39288 has been marked as a duplicate of this bug. ***
`-z common-page-size` is awfully under-documented, so I took a look at GNU gold to understand the semantics. It looks like gold its parameter value to adjust segment offsets so that segments with different attributes (e.g. .text and .data) share the same page (which is mapped to memory twice), if I understand it correctly. In lld, we always round up the end of each segment to the page size. So, it looks like `-z common-page-size` doesn't make sense to be added to lld. We can recognize the flag just to ignore it. But I don't see a reason to really support it.
How does it interact with `-z max-page-size=`? The code we're working with actually sets: -z max-page-size=4096 -z common-page-size=4096 So maybe it's safe to not use common-page-size when max-page-size would have the same value and using LLD? Or are they unrelated?
IIUC, max-page-size affects how segments are aligned in memory. Say, you set max-page-size to 2 MiB. Then all segments are aligned to 2 MiB, so that different segments are mapped to different pages with different page attributes. If you set max-page-size to 4096, and if the runtime OS does not support 4 Ki pages but only 2 MiB large pages, I believe your executable will fail on load time, because your executable is very likely to contain executable and non-executable segments in the same 2 MiB page at the boundary. But this is perhaps hypothetical because I don't think all operating systems that support large pages support both small and large pages. Are you fixing the issue for x86-64/i386? If so, max-page-size is set to 4096 already by default, so I believe you can just remove these flags from the linker command line.
Created attachment 21197 [details] 0001-x86-vdso-drop-implicit-common-page-size-linker-flag.patch
I've submitted the above patch to LKML: https://lkml.org/lkml/2018/12/6/1034 Will close this bug if upstream accepts the patch.
Fix landed in Linux 4.20-rc6 commit ac3e233d29f7f77f28243af0132057d378d3ea58 ("x86/vdso: Drop implicit common-page-size linker flag") So this flag is still not supported in LLD, but it seems that this will be ok going forward; a break from binutils that makes sense IMO. Closing this bug.
I believe Peter Smith is implementing this in LLD.
Support for -z common-page-size is in r360593