This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Help with linking and symbol resolution
- From: Lakshay Garg <lakshaygarg1996+gcc at gmail dot com>
- To: Andrew Haley <aph at redhat dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Sat, 28 Jan 2017 20:40:07 +0530
- Subject: Re: Help with linking and symbol resolution
- Authentication-results: sourceware.org; auth=none
- References: <CAJq3jyziSS4ScBbz5b8szCyAdFHnUfkL0f=BxgZggQHyzzhgYw@mail.gmail.com> <f323cab3-c8be-5534-b45a-f77e06d3d673@redhat.com>
> I do this:
>
> $ gcc f1.c f2.c -Wall
> /usr/local/bin/ld: Warning: alignment 4 of symbol `c' in f2.o is smaller than 8 in f1.o
> /usr/local/bin/ld: Warning: size of symbol `c' changed from 8 in f1.o to 4 in f2.o
>
> You should always use -Wall when gcc does anything unexpected.
>
Hi Andrew
Yes, I get this warning too. But what I want to understand is why do
we get the size of c as 8 when it should be 4 because the linker will
find that there are multiple declarations of c and will keep the
strong one which is the declaration with int.
Please see slides 22,23,24 from here:
https://www.cs.cmu.edu/afs/cs/academic/class/15213-f10/www/lectures/11-linking.pdf
Lakshay G.