I am using readelf to figure out why a binary is so large, but I am confused about the output. Or my binary is linked very wrongly. Right now the binary is approximately 380MB, and if I do this:
readelf -W -s binary | awk 'NR > 3 { sum += $3 } END { print sum }'
I get 236221726 bytes. Seems low, but maybe I'm missing static symbols or what not. But if I do:
readelf -W -s binary | sort -n -r -k 3 | less
I see this:
172766: 000000000cf8d960 99993 FUNC GLOBAL DEFAULT 10 symbolA
147338: 000000000cf8d960 99993 FUNC GLOBAL DEFAULT 10 symbolB
132791: 000000000cf8d960 99993 FUNC GLOBAL DEFAULT 10 symbolA
107363: 000000000cf8d960 99993 FUNC GLOBAL DEFAULT 10 symbolB
Where symbolA and symbolB are only 1 char different, and demangle to the same thing.
So, my questions: 1) If those things have the same address, are there actually four copies in my binary? 2) If there aren't four copies, and these are aliases, shouldn't readelf report that? 3) If the are four copies, how and why? I assume I'm doing something bad linkage-wise. 4) If there aren't four copies, then the summed size from readelf is waaaaay below the actual size of the binary - why?
Edit: Adding some more information... The above readelf output was from the fully linked binary. Looking at just the .o that contains symbolA/symbolB, readelf still reports 1 copy of each symbolA and symbolB, at the same address.
but if I objdump -d the .o file, I only see assembly for symbolA.
So - is objdump or readelf "wrong"?