scripts/kallsyms: Avoid ARM veneer symbols
When building ARM kernels that exceed a certain size, the linker will add "veneers" that allow long branches. Unfortunately, using a longer kallsyms section may lead to the extra veneers being needed, which leads to inconsistent kallsyms data with the message
Inconsistent kallsyms data
Try make KALLSYMS_EXTRA_PASS=1 as a workaround
In some case, not just one but up to three extra passes were needed before getting to a state that needed no extra veneers. The easiest solution is to skip veneers in kallsyms in the same way we already skip a couple of other symbols.
---
scripts/kallsyms.c +24 -6
@@ -69,14 +69,32 @@ static void usage(void)exit (1 ); } -/* -* This ignores the intensely annoying "mapping symbols" found -* in ARM ELF files: $a, $t and $d. -*/ static inline int is_arm_mapping_symbol (const char *str) { -return str[0 ] =='$' &&strchr ("atd" , str[1 ]) - && (str[2 ] =='\0' || str[2 ] =='.' ); +size_t len; + +/* +* This ignores the intensely annoying "mapping symbols" found +* in ARM ELF files: $a, $t and $d. +*/ +if (str[0 ] =='$' &&strchr ("atd" , str[1 ]) + && (str[2 ] =='\0' || str[2 ] =='.' )) +return 1 ; + + len =strlen (str); +if (len <10 ) +return 0 ; + +/* +* This ignores any __.*_veneer symbol, which get +* inserted for large kernels, in order to avoid +* inconsistent data. +*/ +if (str[0 ] =='_' && str[1 ] =='_' && +strcmp (str + len -7 ,"_veneer" ) ==0 ) +return 1 ; + +return 0 ; }static int read_symbol_tr (const char *sym,unsigned long long addr)
Quoted 11 lines · Arnd Bergmann
When building ARM kernels that exceed a certain size, the linker will add "veneers" that allow long branches. Unfortunately, using a longer kallsyms section may lead to the extra veneers being needed, which leads to inconsistent kallsyms data with the message
Inconsistent kallsyms data
Try make KALLSYMS_EXTRA_PASS=1 as a workaroundIn some case, not just one but up to three extra passes were needed before getting to a state that needed no extra veneers.
Do you understand why this was happening? It sounds like there must have been branches crossing from one side of the kallsyms data to the other, triggering veneer insertion any time the kallsyms data grows.
Branches between .{init,exit}.text and .text (crossing .rodata) seem the likeliest culprits, but that's guesswork on my part.
If that's whats going on, multiple kallsyms passes is actually a correct approach here: I think they should terminate after a number of steps roughly proportional to log(number of branches across .rodata). We could come up with a heuristic which allows us to choose the right limit with a high degree of reliability, since branch density in compiled C code is likely to be roughly.
But including the veneer symbols in kallsyms is arguably not all that useful.
The main potential effect is that profiling might occasionally sample the PC as being in a completely bogus function which it never passed through at all, because of the way kallsyms tracks only symbol locations and not sizes (if I remember right) -- so a veneer will actually get accounted against some arbitrary adjacent function.
I don't know how much this matters.
Quoted 2 lines
The easiest solution is to skip veneers in kallsyms in the same way we already skip a couple of other symbols.
The other symbols are not stripped for the purpose of making kallsyms terminate quickly. The mapping symbols are rather
different: masses of symbols with duplicate names which are not very interesting for most people.
Quoted 8 lines
Signed-off-by Arnd Bergmann <[email protected]>---
scripts/kallsyms.c +0
-0
scripts/kallsyms.c static void usage(void) · line 72
Quoted 8 lines
scripts/kallsyms.c +0
-4@@ -69,14 +69,32 @@ static void usage(void)exit (1 ); } -/* -* This ignores the intensely annoying "mapping symbols" found -* in ARM ELF files: $a, $t and $d. -*/ static inline int is_arm_mapping_symbol (const char *str)
The function's name is now wrong. Should it be renamed or split up?
Cheers
---Dave
Quoted 36 lines
scripts/kallsyms.c +24
-2{ -return str[0 ] =='$' &&strchr ("atd" , str[1 ]) - && (str[2 ] =='\0' || str[2 ] =='.' ); +size_t len; + +/* +* This ignores the intensely annoying "mapping symbols" found +* in ARM ELF files: $a, $t and $d. +*/ +if (str[0 ] =='$' &&strchr ("atd" , str[1 ]) + && (str[2 ] =='\0' || str[2 ] =='.' )) +return 1 ; + + len =strlen (str); +if (len <10 ) +return 0 ; + +/* +* This ignores any __.*_veneer symbol, which get +* inserted for large kernels, in order to avoid +* inconsistent data. +*/ +if (str[0 ] =='_' && str[1 ] =='_' && +strcmp (str + len -7 ,"_veneer" ) ==0 ) +return 1 ; + +return 0 ; }static int read_symbol_tr (const char *sym,unsigned long long addr)_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 13 lines · Dave Martin
Quoted 11 lines · Arnd Bergmann
When building ARM kernels that exceed a certain size, the linker will add "veneers" that allow long branches. Unfortunately, using a longer kallsyms section may lead to the extra veneers being needed, which leads to inconsistent kallsyms data with the message
Inconsistent kallsyms data
Try make KALLSYMS_EXTRA_PASS=1 as a workaroundIn some case, not just one but up to three extra passes were needed before getting to a state that needed no extra veneers.
Quoted 7 lines
Do you understand why this was happening? It sounds like there must have been branches crossing from one side of the kallsyms data to the other, triggering veneer insertion any time the kallsyms data grows.
Branches between .{init,exit}.text and .text (crossing .rodata) seem the likeliest culprits, but that's guesswork on my part.
kallsyms is part of rodata, which is between .text and .init.text. I understand this is intentional, and we already use two passes of kallsyms to make sure the size is right. However the assumption is that only the data of the kallsyms table changes between runs, not the size of it.
Quoted 6 lines
If that's whats going on, multiple kallsyms passes is actually a correct approach here: I think they should terminate after a number of steps roughly proportional to log(number of branches across .rodata). We could come up with a heuristic which allows us to choose the right limit with a high degree of reliability, since branch density in compiled C code is likely to be roughly.
It also seems to be a part of the design to do exactly two passes and treat anything beyond that as bugs, doing it the way you suggest would significantly increase the build time since the kallsyms+linker stage cannot be done in parallel or sped up using ccache.
Quoted 11 lines
But including the veneer symbols in kallsyms is arguably not all that useful.
The main potential effect is that profiling might occasionally sample the PC as being in a completely bogus function which it never passed through at all, because of the way kallsyms tracks only symbol locations and not sizes (if I remember right) -- so a veneer will actually get accounted against some arbitrary adjacent function.
I don't know how much this matters.
Interesting point. No idea how often that happens. All the veneers for one section are in one place though, so we could in theory add a kallsyms entry for that section as long as can identify it.
Quoted 7 lines
Quoted 2 lines
The easiest solution is to skip veneers in kallsyms in the same way we already skip a couple of other symbols.
The other symbols are not stripped for the purpose of making kallsyms terminate quickly. The mapping symbols are rather
different: masses of symbols with duplicate names which are not very interesting for most people.
Right.
Quoted 10 lines
Quoted 10 lines
Signed-off-by Arnd Bergmann <[email protected]>---
scripts/kallsyms.c +0
-0@@ -69,14 +69,32 @@ static void usage(void)exit (1 ); }
Quoted 7 lines
scripts/kallsyms.c static void usage(void) · line 72
Quoted 5 lines
scripts/kallsyms.c +0
-4-/* -* This ignores the intensely annoying "mapping symbols" found -* in ARM ELF files: $a, $t and $d. -*/ static inline int is_arm_mapping_symbol (const char *str)The function's name is now wrong. Should it be renamed or split up?
Sure I can rename it. Any suggestions?
Arnd
Quoted 19 lines · Arnd Bergmann
Quoted 18 lines · Dave Martin
Quoted 11 lines · Arnd Bergmann
When building ARM kernels that exceed a certain size, the linker will add "veneers" that allow long branches. Unfortunately, using a longer kallsyms section may lead to the extra veneers being needed, which leads to inconsistent kallsyms data with the message
Inconsistent kallsyms data
Try make KALLSYMS_EXTRA_PASS=1 as a workaroundIn some case, not just one but up to three extra passes were needed before getting to a state that needed no extra veneers.
Do you understand why this was happening? It sounds like there must have been branches crossing from one side of the kallsyms data to the other, triggering veneer insertion any time the kallsyms data grows.
Quoted 8 lines
Quoted 2 lines
Branches between .{init,exit}.text and .text (crossing .rodata) seem the likeliest culprits, but that's guesswork on my part.
kallsyms is part of rodata, which is between .text and .init.text. I understand this is intentional, and we already use two passes of kallsyms to make sure the size is right. However the assumption is that only the data of the kallsyms table changes between runs, not the size of it.
I guess sticking the init stuff at the end makes it tidier to discard without leaving a gap in the middle of the kernel image. There might be other reasons.
Quoted 9 lines
Quoted 6 lines
If that's whats going on, multiple kallsyms passes is actually a correct approach here: I think they should terminate after a number of steps roughly proportional to log(number of branches across .rodata). We could come up with a heuristic which allows us to choose the right limit with a high degree of reliability, since branch density in compiled C code is likely to be roughly.
It also seems to be a part of the design to do exactly two passes and treat anything beyond that as bugs, doing it the way you
Sure -- I was that making the point the implementation is based on an assumption that isn't true here.
Quoted 14 lines
suggest would significantly increase the build time since the kallsyms+linker stage cannot be done in parallel or sped up using ccache.
Quoted 10 lines
But including the veneer symbols in kallsyms is arguably not all that useful.
The main potential effect is that profiling might occasionally sample the PC as being in a completely bogus function which it never passed through at all, because of the way kallsyms tracks only symbol locations and not sizes (if I remember right) -- so a veneer will actually get accounted against some arbitrary adjacent function.
Quoted 6 lines
Quoted 1 line
I don't know how much this matters.
Interesting point. No idea how often that happens. All the veneers for one section are in one place though, so we could in theory add a kallsyms entry for that section as long as can identify it.
We could collapse any contiguous sequence of __veneer_* symbols down to a single symbol to mark those holes.
However, many kallsyms passes could still be needed: each pass might add extra veneer blocks, unless the size of kallsyms data is identical to that in the previous pass. The expected convergence rate is faster, though.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
The easiest solution is to skip veneers in kallsyms in the same way we already skip a couple of other symbols.
Your suggestion of omitting the symbols completely seems to be the only way to ensure convergence in 2 passes, so far as I can see.
Adding size information to every entry in kallsyms would make it possible to identify the "holes" without potentially requiring many kallsyms passes, but it would bloat the table. The extra info would be interesting only for a tiny subset of the symbols. I expect people aren't going to like that much.
So I guess your original suggestion may be the best thing to do for now, after all...
There is no proper reserved symbol namespace for linker-generated symbols, so a real symbol could have the name __*_veneer, at which point things start to get really confusing. But hopefully that won't happen much. I don't see any such symbol right now, and hopefully nobody will be so silly as to add one...
If we eventually need to fix the bogus symbol resolution problem, I can't see an alternative to adding size info to every symbol. But we should leave that for now. It doesn't sound like a serious problem.
Quoted 25 lines
Quoted 4 lines
The other symbols are not stripped for the purpose of making kallsyms terminate quickly. The mapping symbols are rather
different: masses of symbols with duplicate names which are not very interesting for most people.Right.
Quoted 10 lines
Quoted 10 lines
Signed-off-by Arnd Bergmann <[email protected]>---
scripts/kallsyms.c +0
-0@@ -69,14 +69,32 @@ static void usage(void)exit (1 ); }Quoted 7 lines
scripts/kallsyms.c static void usage(void) · line 72
Quoted 5 lines
scripts/kallsyms.c +0
-4-/* -* This ignores the intensely annoying "mapping symbols" found -* in ARM ELF files: $a, $t and $d. -*/ static inline int is_arm_mapping_symbol (const char *str)The function's name is now wrong. Should it be renamed or split up?
Quoted 1 line
Sure I can rename it. Any suggestions?
Maybe just something more generic like is_arm_special_symbol()?
Cheers
---Dave
Quoted 23 lines · Dave P Martin
Quoted 15 lines · Arnd Bergmann
On Tuesday 25 June 2013, Dave Martin wrote:
suggest would significantly increase the build time since the kallsyms+linker stage cannot be done in parallel or sped up using ccache.Quoted 10 lines
But including the veneer symbols in kallsyms is arguably not all that useful.
The main potential effect is that profiling might occasionally sample the PC as being in a completely bogus function which it never passed through at all, because of the way kallsyms tracks only symbol locations and not sizes (if I remember right) -- so a veneer will actually get accounted against some arbitrary adjacent function.
Quoted 6 lines
Quoted 1 line
I don't know how much this matters.
Interesting point. No idea how often that happens. All the veneers for one section are in one place though, so we could in theory add a kallsyms entry for that section as long as can identify it.
Quoted 7 lines
We could collapse any contiguous sequence of __veneer_* symbols down to a single symbol to mark those holes.
However, many kallsyms passes could still be needed: each pass might add extra veneer blocks, unless the size of kallsyms data is identical to that in the previous pass. The expected convergence rate is faster, though.
Right, it wouldn't guarantee to converge after two passes, just make it very likely.
Quoted 22 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
The easiest solution is to skip veneers in kallsyms in the same way we already skip a couple of other symbols.
Your suggestion of omitting the symbols completely seems to be the only way to ensure convergence in 2 passes, so far as I can see.
Adding size information to every entry in kallsyms would make it possible to identify the "holes" without potentially requiring many kallsyms passes, but it would bloat the table. The extra info would be interesting only for a tiny subset of the symbols. I expect people aren't going to like that much.
So I guess your original suggestion may be the best thing to do for now, after all...
There is no proper reserved symbol namespace for linker-generated symbols, so a real symbol could have the name __*_veneer, at which point things start to get really confusing. But hopefully that won't happen much. I don't see any such symbol right now, and hopefully nobody will be so silly as to add one...
Quoted 3 lines
If we eventually need to fix the bogus symbol resolution problem, I can't see an alternative to adding size info to every symbol. But we should leave that for now. It doesn't sound like a serious problem.
Unfortunately I have run into additional problems now after doing a few hundred more builds:
* not all veneers end in _veneer, some also end in _from_arm or _from_thumb. This is easy enough to check for in the same way I did for _veneer.
* There are actually symbols without a name on ARM, which screws up the kallsyms.c parser. These also seem to be veneers, but attached to some random function:
$ nm obj-tmp/.tmp_vmlinux1 | head c09e8db1 t c09e8db5 t c09e8db9 t # <========== c09e8dbd t c0abfc29 t c0008000 t $a c0f7b640 t $a
$ objdump -Dr obj-tmp/.tmp_vmlinux1 | grep -C 30 c09e8db.
c0851fcc <wlc_phy_edcrs_lock>:
c0851fcc: b538 push {r3, r4, r5, lr}
c0851fce: b500 push {lr}
c0851fd0: f7bb d8dc bl c000d18c <__gnu_mcount_nc>
c0851fd4: f240 456b movw r5, #1131 ; 0x46b
c0851fd8: 4604 mov r4, r0
c0851fda: f880 14d5 strb.w r1, [r0, #1237] ; 0x4d5
c0851fde: 462a mov r2, r5
c0851fe0: f44f 710b mov.w r1, #556 ; 0x22c
c0851fe4: f7ff fe6d bl c0851cc2 <write_phy_reg>
c0851fe8: 4620 mov r0, r4
c0851fea: 462a mov r2, r5
c0851fec: f240 212d movw r1, #557 ; 0x22d
c0851ff0: f7ff fe67 bl c0851cc2 <write_phy_reg>
c0851ff4: 4620 mov r0, r4
c0851ff6: f240 212e movw r1, #558 ; 0x22e
c0851ffa: f44f 7270 mov.w r2, #960 ; 0x3c0
c0851ffe: f196 fedb bl c09e8db8 <tpci200_free_irq+0x78> # <===========
c0852002: 4620 mov r0, r4
c0852004: f240 212f movw r1, #559 ; 0x22f
c0852008: f44f 7270 mov.w r2, #960 ; 0x3c0
c085200c: e8bd 4038 ldmia.w sp!, {r3, r4, r5, lr}
c0852010: f7ff be57 b.w c0851cc2 <write_phy_reg>... # in tpci200_free_irq:
c09e8d9e: e003 b.n c09e8da8 <tpci200_free_irq+0x68>
c09e8da0: f06f 0415 mvn.w r4, #21
c09e8da4: e000 b.n c09e8da8 <tpci200_free_irq+0x68>
c09e8da6: 4c01 ldr r4, [pc, #4] ; (c09e8dac <tpci200_free_irq+0x6c>)
c09e8da8: 4620 mov r0, r4
c09e8daa: bdf8 pop {r3, r4, r5, r6, r7, pc}
c09e8dac: fffffe00 ; <UNDEFINED> instruction: 0xfffffe00
c09e8db0: f4cf b814 b.w c06b7ddc <bna_enet_sm_chld_stop_wait_entry>
c09e8db4: f53e bed8 b.w c0727b68 <gem_do_stop>
c09e8db8: f668 bf83 b.w c0851cc2 <write_phy_reg> # <==========
c09e8dbc: d101 bne.n c09e8dc2 <tpci200_free_irq+0x82>
c09e8dbe: f435 b920 b.w c061e002 <twl_reset_sequence+0x34c>It makes no sense to me at all that a function in one driver can just call write_phy_reg a couple of times, but need a veneer in the middle, and put that veneer in a totally unrelated function in another driver!
If this is a binutils bug or gcc bug, we should probably just fix it, but it might be easier to work around it by changing kallsyms.c some more.
Quoted 11 lines
Quoted 9 lines
Quoted 7 lines
Quoted 5 lines
-/*
- * This ignores the intensely annoying "mapping symbols" found
- * in ARM ELF files: $a, $t and $d.
- */
static inline intis_arm_mapping_symbol(const char *str)The function's name is now wrong. Should it be renamed or split up?
Sure I can rename it. Any suggestions?
Maybe just something more generic like
is_arm_special_symbol()?
Ok, I can do that.
Arnd
Quoted 61 lines · Arnd Bergmann
Quoted 23 lines · Dave P Martin
Quoted 15 lines · Arnd Bergmann
On Tuesday 25 June 2013, Dave Martin wrote:
suggest would significantly increase the build time since the kallsyms+linker stage cannot be done in parallel or sped up using ccache.Quoted 10 lines
But including the veneer symbols in kallsyms is arguably not all that useful.
The main potential effect is that profiling might occasionally sample the PC as being in a completely bogus function which it never passed through at all, because of the way kallsyms tracks only symbol locations and not sizes (if I remember right) -- so a veneer will actually get accounted against some arbitrary adjacent function.
Quoted 6 lines
Quoted 1 line
I don't know how much this matters.
Interesting point. No idea how often that happens. All the veneers for one section are in one place though, so we could in theory add a kallsyms entry for that section as long as can identify it.
Quoted 7 lines
We could collapse any contiguous sequence of __veneer_* symbols down to a single symbol to mark those holes.
However, many kallsyms passes could still be needed: each pass might add extra veneer blocks, unless the size of kallsyms data is identical to that in the previous pass. The expected convergence rate is faster, though.
Right, it wouldn't guarantee to converge after two passes, just make it very likely.
Quoted 22 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
The easiest solution is to skip veneers in kallsyms in the same way we already skip a couple of other symbols.
Your suggestion of omitting the symbols completely seems to be the only way to ensure convergence in 2 passes, so far as I can see.
Adding size information to every entry in kallsyms would make it possible to identify the "holes" without potentially requiring many kallsyms passes, but it would bloat the table. The extra info would be interesting only for a tiny subset of the symbols. I expect people aren't going to like that much.
So I guess your original suggestion may be the best thing to do for now, after all...
There is no proper reserved symbol namespace for linker-generated symbols, so a real symbol could have the name __*_veneer, at which point things start to get really confusing. But hopefully that won't happen much. I don't see any such symbol right now, and hopefully nobody will be so silly as to add one...
Quoted 3 lines
If we eventually need to fix the bogus symbol resolution problem, I can't see an alternative to adding size info to every symbol. But we should leave that for now. It doesn't sound like a serious problem.
Quoted 5 lines
Unfortunately I have run into additional problems now after doing a few hundred more builds:
* not all veneers end in
_veneer, some also end in_from_armor_from_thumb. This is easy enough to check for in the same way I did for_veneer.
I think there are a small number of patterns to check for.
__*_veneer, __*_from_arm and __*_from_thumb should cover most cases.
Quoted 3 lines
* There are actually symbols without a name on ARM, which screws up the
kallsyms.cparser. These also seem to be veneers, but attached to some random function:
Hmmm, I don't what those are. By default, we should probably ignore those too. Maybe they have something to do with link-time relocation processing.
Quoted 50 lines
$ nm obj-tmp/.tmp_vmlinux1 | head c09e8db1 t c09e8db5 t c09e8db9 t # <========== c09e8dbd t c0abfc29 t c0008000 t $a c0f7b640 t $a$ objdump -Dr obj-tmp/.tmp_vmlinux1 | grep -C 30 c09e8db. c0851fcc <wlc_phy_edcrs_lock>: c0851fcc: b538 push {r3, r4, r5, lr} c0851fce: b500 push {lr} c0851fd0: f7bb d8dc bl c000d18c <__gnu_mcount_nc> c0851fd4: f240 456b movw r5, #1131 ; 0x46b c0851fd8: 4604 mov r4, r0 c0851fda: f880 14d5 strb.w r1, [r0, #1237] ; 0x4d5 c0851fde: 462a mov r2, r5 c0851fe0: f44f 710b mov.w r1, #556 ; 0x22c c0851fe4: f7ff fe6d bl c0851cc2 <write_phy_reg> c0851fe8: 4620 mov r0, r4 c0851fea: 462a mov r2, r5 c0851fec: f240 212d movw r1, #557 ; 0x22d c0851ff0: f7ff fe67 bl c0851cc2 <write_phy_reg> c0851ff4: 4620 mov r0, r4 c0851ff6: f240 212e movw r1, #558 ; 0x22e c0851ffa: f44f 7270 mov.w r2, #960 ; 0x3c0 c0851ffe: f196 fedb bl c09e8db8 <tpci200_free_irq+0x78> # <=========== c0852002: 4620 mov r0, r4 c0852004: f240 212f movw r1, #559 ; 0x22f c0852008: f44f 7270 mov.w r2, #960 ; 0x3c0 c085200c: e8bd 4038 ldmia.w sp!, {r3, r4, r5, lr} c0852010: f7ff be57 b.w c0851cc2 <write_phy_reg>... # in
tpci200_free_irq:c09e8d9e: e003 b.n c09e8da8 <tpci200_free_irq+0x68> c09e8da0: f06f 0415 mvn.w r4, #21 c09e8da4: e000 b.n c09e8da8 <tpci200_free_irq+0x68> c09e8da6: 4c01 ldr r4, [pc, #4] ; (c09e8dac <tpci200_free_irq+0x6c>) c09e8da8: 4620 mov r0, r4 c09e8daa: bdf8 pop {r3, r4, r5, r6, r7, pc} c09e8dac: fffffe00 ; <UNDEFINED> instruction: 0xfffffe00 c09e8db0: f4cf b814 b.w c06b7ddc <bna_enet_sm_chld_stop_wait_entry> c09e8db4: f53e bed8 b.w c0727b68 <gem_do_stop> c09e8db8: f668 bf83 b.w c0851cc2 <write_phy_reg> # <========== c09e8dbc: d101 bne.n c09e8dc2 <tpci200_free_irq+0x82> c09e8dbe: f435 b920 b.w c061e002 <twl_reset_sequence+0x34c>
Quoted 3 lines
It makes no sense to me at all that a function in one driver can just call
write_phy_rega couple of times, but need a veneer in the middle, and put that veneer in a totally unrelated function in another driver!
I think that if ld inserts a veneer for a function anywhere, branches from any object in the link to that target symbol can reuse the same veneer as a trampoline, effectively appearing to branch through an unrelated location to reach the destination.
ld inserts veneers between individual input sections, but I don't think they have to go next to the same section the branch originates from. In the above code, it looks like that series of unconditional branches after the end of tpci200_free_irq might be a common veneer pool for many different destinations.
LTO may also make the expected compilation unit boundaries disappear completely. Anything could end up almost anywhere in that case. Files could get intermingled, inlined and generally spread all over the place.
Even so, veneers shouldn't be needed in the common case where we're not jumping across .rodata.
Quoted 3 lines
If this is a binutils bug or gcc bug, we should probably just fix it, but it might be easier to work around it by changing
kallsyms.csome more.
I haven't found a trivial way to reproduce those nameless symbols. I don't know whether they're a bug or not...
Making kallsyms robust against this might be a good idea anyway.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
-/*
- * This ignores the intensely annoying "mapping symbols" found
- * in ARM ELF files: $a, $t and $d.
- */
static inline intis_arm_mapping_symbol(const char *str)
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
The function's name is now wrong. Should it be renamed or split up?
Sure I can rename it. Any suggestions?
Maybe just something more generic like
is_arm_special_symbol()?Ok, I can do that.
Cheers
---Dave
Quoted 7 lines · Dave P Martin
Quoted 2 lines · Arnd Bergmann
Quoted 1 line · Dave P Martin
On Wed, Jul 03, 2013 at 06:03:04PM +0200, Arnd Bergmann wrote:
I think there are a small number of patterns to check for.
__*_veneer, __*_from_arm and __*_from_thumb should cover most cases.
Ok.
Quoted 6 lines
Quoted 3 lines
* There are actually symbols without a name on ARM, which screws up the
kallsyms.cparser. These also seem to be veneers, but attached to some random function:Hmmm, I don't what those are. By default, we should probably ignore those too. Maybe they have something to do with link-time relocation processing.
Definitely link-time. It only shows up after the final link, and only with ld.bfd not with ld.gold as I found out now.
Quoted 49 lines
Quoted 49 lines
$ nm obj-tmp/.tmp_vmlinux1 | head c09e8db1 t c09e8db5 t c09e8db9 t # <========== c09e8dbd t c0abfc29 t c0008000 t $a c0f7b640 t $a$ objdump -Dr obj-tmp/.tmp_vmlinux1 | grep -C 30 c09e8db. c0851fcc <wlc_phy_edcrs_lock>: c0851fcc: b538 push {r3, r4, r5, lr} c0851fce: b500 push {lr} c0851fd0: f7bb d8dc bl c000d18c <__gnu_mcount_nc> c0851fd4: f240 456b movw r5, #1131 ; 0x46b c0851fd8: 4604 mov r4, r0 c0851fda: f880 14d5 strb.w r1, [r0, #1237] ; 0x4d5 c0851fde: 462a mov r2, r5 c0851fe0: f44f 710b mov.w r1, #556 ; 0x22c c0851fe4: f7ff fe6d bl c0851cc2 <write_phy_reg> c0851fe8: 4620 mov r0, r4 c0851fea: 462a mov r2, r5 c0851fec: f240 212d movw r1, #557 ; 0x22d c0851ff0: f7ff fe67 bl c0851cc2 <write_phy_reg> c0851ff4: 4620 mov r0, r4 c0851ff6: f240 212e movw r1, #558 ; 0x22e c0851ffa: f44f 7270 mov.w r2, #960 ; 0x3c0 c0851ffe: f196 fedb bl c09e8db8 <tpci200_free_irq+0x78> # <=========== c0852002: 4620 mov r0, r4 c0852004: f240 212f movw r1, #559 ; 0x22f c0852008: f44f 7270 mov.w r2, #960 ; 0x3c0 c085200c: e8bd 4038 ldmia.w sp!, {r3, r4, r5, lr} c0852010: f7ff be57 b.w c0851cc2 <write_phy_reg>... # in
tpci200_free_irq:c09e8d9e: e003 b.n c09e8da8 <tpci200_free_irq+0x68> c09e8da0: f06f 0415 mvn.w r4, #21 c09e8da4: e000 b.n c09e8da8 <tpci200_free_irq+0x68> c09e8da6: 4c01 ldr r4, [pc, #4] ; (c09e8dac <tpci200_free_irq+0x6c>) c09e8da8: 4620 mov r0, r4 c09e8daa: bdf8 pop {r3, r4, r5, r6, r7, pc} c09e8dac: fffffe00 ; <UNDEFINED> instruction: 0xfffffe00 c09e8db0: f4cf b814 b.w c06b7ddc <bna_enet_sm_chld_stop_wait_entry> c09e8db4: f53e bed8 b.w c0727b68 <gem_do_stop> c09e8db8: f668 bf83 b.w c0851cc2 <write_phy_reg> # <========== c09e8dbc: d101 bne.n c09e8dc2 <tpci200_free_irq+0x82> c09e8dbe: f435 b920 b.w c061e002 <twl_reset_sequence+0x34c>
Quoted 8 lines
Quoted 3 lines
It makes no sense to me at all that a function in one driver can just call
write_phy_rega couple of times, but need a veneer in the middle, and put that veneer in a totally unrelated function in another driver!I think that if ld inserts a veneer for a function anywhere, branches from any object in the link to that target symbol can reuse the same veneer as a trampoline, effectively appearing to branch through an unrelated location to reach the destination.
That part makes sense, but it doesn't explain why ld would do that just for the third out of four identical function calls in the example above.
Quoted 5 lines
ld inserts veneers between individual input sections, but I don't think they have to go next to the same section the branch originates from. In the above code, it looks like that series of unconditional branches after the end of
tpci200_free_irqmight be a common veneer pool for many different destinations.
Yes, exactly. In this build I had six of these nameless symbols, and five of them were in this one function.
Quoted 4 lines
LTO may also make the expected compilation unit boundaries disappear completely. Anything could end up almost anywhere in that case. Files could get intermingled, inlined and generally spread all over the place.
I'm not sure we actually want to enable that in the kernel ;-)
In particular in combination with kallsyms, it would make the kallsyms information rather useless when we can no longer infer a function name from an address.
Quoted 11 lines
Even so, veneers shouldn't be needed in the common case where we're not jumping across .rodata.
Quoted 3 lines
If this is a binutils bug or gcc bug, we should probably just fix it, but it might be easier to work around it by changing
kallsyms.csome more.I haven't found a trivial way to reproduce those nameless symbols. I don't know whether they're a bug or not...
Making kallsyms robust against this might be a good idea anyway.
Maybe we can find a binutils expert next week at Linaro connect to take a look at the data. I can prepare a test case.
Arnd
Quoted 96 lines · Arnd Bergmann
Quoted 7 lines · Dave P Martin
Quoted 2 lines · Arnd Bergmann
Quoted 1 line · Dave P Martin
On Wed, Jul 03, 2013 at 06:03:04PM +0200, Arnd Bergmann wrote:
I think there are a small number of patterns to check for.
__*_veneer, __*_from_arm and __*_from_thumb should cover most cases.
Ok.
Quoted 6 lines
Quoted 3 lines
* There are actually symbols without a name on ARM, which screws up the
kallsyms.cparser. These also seem to be veneers, but attached to some random function:Hmmm, I don't what those are. By default, we should probably ignore those too. Maybe they have something to do with link-time relocation processing.
Definitely link-time. It only shows up after the final link, and only with ld.bfd not with ld.gold as I found out now.
Quoted 49 lines
Quoted 49 lines
$ nm obj-tmp/.tmp_vmlinux1 | head c09e8db1 t c09e8db5 t c09e8db9 t # <========== c09e8dbd t c0abfc29 t c0008000 t $a c0f7b640 t $a$ objdump -Dr obj-tmp/.tmp_vmlinux1 | grep -C 30 c09e8db. c0851fcc <wlc_phy_edcrs_lock>: c0851fcc: b538 push {r3, r4, r5, lr} c0851fce: b500 push {lr} c0851fd0: f7bb d8dc bl c000d18c <__gnu_mcount_nc> c0851fd4: f240 456b movw r5, #1131 ; 0x46b c0851fd8: 4604 mov r4, r0 c0851fda: f880 14d5 strb.w r1, [r0, #1237] ; 0x4d5 c0851fde: 462a mov r2, r5 c0851fe0: f44f 710b mov.w r1, #556 ; 0x22c c0851fe4: f7ff fe6d bl c0851cc2 <write_phy_reg> c0851fe8: 4620 mov r0, r4 c0851fea: 462a mov r2, r5 c0851fec: f240 212d movw r1, #557 ; 0x22d c0851ff0: f7ff fe67 bl c0851cc2 <write_phy_reg> c0851ff4: 4620 mov r0, r4 c0851ff6: f240 212e movw r1, #558 ; 0x22e c0851ffa: f44f 7270 mov.w r2, #960 ; 0x3c0 c0851ffe: f196 fedb bl c09e8db8 <tpci200_free_irq+0x78> # <=========== c0852002: 4620 mov r0, r4 c0852004: f240 212f movw r1, #559 ; 0x22f c0852008: f44f 7270 mov.w r2, #960 ; 0x3c0 c085200c: e8bd 4038 ldmia.w sp!, {r3, r4, r5, lr} c0852010: f7ff be57 b.w c0851cc2 <write_phy_reg>... # in
tpci200_free_irq:c09e8d9e: e003 b.n c09e8da8 <tpci200_free_irq+0x68> c09e8da0: f06f 0415 mvn.w r4, #21 c09e8da4: e000 b.n c09e8da8 <tpci200_free_irq+0x68> c09e8da6: 4c01 ldr r4, [pc, #4] ; (c09e8dac <tpci200_free_irq+0x6c>) c09e8da8: 4620 mov r0, r4 c09e8daa: bdf8 pop {r3, r4, r5, r6, r7, pc} c09e8dac: fffffe00 ; <UNDEFINED> instruction: 0xfffffe00 c09e8db0: f4cf b814 b.w c06b7ddc <bna_enet_sm_chld_stop_wait_entry> c09e8db4: f53e bed8 b.w c0727b68 <gem_do_stop> c09e8db8: f668 bf83 b.w c0851cc2 <write_phy_reg> # <========== c09e8dbc: d101 bne.n c09e8dc2 <tpci200_free_irq+0x82> c09e8dbe: f435 b920 b.w c061e002 <twl_reset_sequence+0x34c>Quoted 8 lines
Quoted 3 lines
It makes no sense to me at all that a function in one driver can just call
write_phy_rega couple of times, but need a veneer in the middle, and put that veneer in a totally unrelated function in another driver!I think that if ld inserts a veneer for a function anywhere, branches from any object in the link to that target symbol can reuse the same veneer as a trampoline, effectively appearing to branch through an unrelated location to reach the destination.
That part makes sense, but it doesn't explain why ld would do that just for the third out of four identical function calls in the example above.
Quoted 5 lines
ld inserts veneers between individual input sections, but I don't think they have to go next to the same section the branch originates from. In the above code, it looks like that series of unconditional branches after the end of
tpci200_free_irqmight be a common veneer pool for many different destinations.Yes, exactly. In this build I had six of these nameless symbols, and five of them were in this one function.
Quoted 4 lines
LTO may also make the expected compilation unit boundaries disappear completely. Anything could end up almost anywhere in that case. Files could get intermingled, inlined and generally spread all over the place.
Quoted 5 lines
I'm not sure we actually want to enable that in the kernel ;-)
In particular in combination with kallsyms, it would make the kallsyms information rather useless when we can no longer infer a function name from an address.
Well, indeed. But that's a separate discussion -- I don't think we want to block it needlessly just due to an obscure feature of the ARM toolchain.
Ignoring veneers and nameless symbols in kallsyms sounds like a reasonable approach for now, even if it's not a perfect.
Quoted 7 lines
Quoted 7 lines
Even so, veneers shouldn't be needed in the common case where we're not jumping across .rodata.
Quoted 3 lines
If this is a binutils bug or gcc bug, we should probably just fix it, but it might be easier to work around it by changing
kallsyms.csome more.
Quoted 7 lines
Quoted 4 lines
I haven't found a trivial way to reproduce those nameless symbols. I don't know whether they're a bug or not...
Making kallsyms robust against this might be a good idea anyway.
Maybe we can find a binutils expert next week at Linaro connect to take a look at the data. I can prepare a test case.
Sure, that could be worth a try.
Cheers
---Dave