Since the beginning of time (or at least 1970) unix/linux C has allowed non/un initialized data object to be overlayed in multiple object files even if different sizes. Apparently this is now “broken” in Red Hat 9.
k1.c
char overlay[1024];
int main(int argc, char *argv[]){
void xmain();
xmain();
}
k2.c
char overlay[1024];
int xmain(){
}
Red hat 8:
[jon@rh8x ~]$ cc k1.c k2.c -o k
[jon@rh8x ~]$
red hat 9
[jon@rhel9 ~]$ cc k1.c k2.c -o k
/usr/bin/ld: /tmp/ccnCZBZM.o:(.bss+0x0): multiple definition of `overlay’; /tmp/cca4vlOT.o:(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status
[jon@rhel9 ~]$
passing -fcommon to ld solves the problem but -fcommon is “frowned upon” and may disappear in later releases and shouldn’t be necessary as overlayed uninitialized data is part of the C/unix standard..
[jon@rhel9 ~]$ cc -fcommon k1.c k2.c -o k
[jon@rhel9 ~]$
does anyone have any wisdom as to what is going on in RHEL9 ?
Jon Power is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.