On Fri, Apr 08, 2016 at 06:25:23PM +0200, Albert Netymk wrote: > test.c > ``` > void my_fun(int *arr, int N) > { > int sum = 0; > for (int i = 0; i < N; ++i) { > sum += arr[i]; > } > } > > int main(void) > { > return 0; > } > ``` > clang -c -g test.c ; objdump -S test.o > test.s > > `my_fun` appears twice in the disassembly code. > Excerpt of test.s: [snip]
Please take a look at the .debug_line info in your object file with "readelf -wl test.o". I expect you will see negative advances of line number, at the address where you see repeated source lines. This is normal. Compilers will emit code corresponding to a single line, at different locations. This happens even at -O0, particularly around loops. So you should expect this line for (int i = 0; i < N; ++i) { to be repeated. objdump also shows some context lines before the repeated line. That's why my_fun appears twice. We could probably fix that. You'll also notice repeated source lines after the negative advance of line number that don't actually corresponded to code at those locations. In this case sum += arr[i]; We can't do much about that.. -- Alan Modra Australia Development Lab, IBM _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils