https://sourceware.org/bugzilla/show_bug.cgi?id=26580
Bug ID: 26580 Summary: Size and alignment from as-needed shared library bss symbols affect commons Product: binutils Version: 2.36 (HEAD) Status: NEW Severity: normal Priority: P2 Component: ld Assignee: unassigned at sourceware dot org Reporter: amodra at gmail dot com Target Milestone: --- An as-needed shared library that isn't needed can affect common symbol size and alignment. cat > a.c <<\EOF #include <stdio.h> extern void __attribute__ ((weak)) foo (void); char x, y, z; long lowest_align (void *a, void *b, void *c) { unsigned long bits = (long) a | (long) b | (long) c; return bits & -bits; } int main (void) { printf ("library %sloaded\n", &foo ? "" : "not "); printf ("alignment %ld\n", lowest_align (&x, &y, &z)); return 0; } EOF cat > b.c <<\EOF long long x, y, z; void foo (void) {} EOF gcc -O2 -fpic -fcommon -shared -o libb.so b.c gcc -O2 -fpic -fcommon -o y1 a.c -Wl,--no-as-needed,-R,. libb.so ./y1 library loaded alignment 8 gcc -O2 -fpic -fcommon -o y2 a.c -Wl,--as-needed,-R,. libb.so ./y2 library not loaded alignment 8 gcc -O2 -fpic -fcommon -o y3 a.c ./y3 library not loaded alignment 1 I reckon y2 and y3 should print the same result. -- You are receiving this mail because: You are on the CC list for the bug.