On Sat, 19 Nov 2016, Janne Grunau wrote:
On 2016-11-18 23:47:21 +0200, Martin Storsjö wrote:On Fri, 18 Nov 2016, Janne Grunau wrote:This catches errors manifesting only on position independent ELF builds on all configurations. This still can be fooled by using register aliases or the special name 'ip' for r12. --- libavutil/arm/asm.S | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/libavutil/arm/asm.S b/libavutil/arm/asm.S index 4ac0ea2..e2fe463 100644 --- a/libavutil/arm/asm.S +++ b/libavutil/arm/asm.S @@ -184,6 +184,25 @@ T ldr \rd, [\rd] .endm .macro movrelx rd, val, gp + .ifc \rd,\gp + .error "movrelx needs two distinct registers" + .endif + .ifc \rd_\gp,r12_This needs \() inbetween \rd and _\gpYes, but it does work here as intended. Strange.
Hmm, strange indeed.
+ .ifn .Lpic_gp + .error "movrelx rd=r12, needs a manually set gp" + .elseif .Lpic_gp == 12 + .error "movrelx rd=r12, needs a manually set gp" + .endif + .endif + .ifnb \gp + .ifc \gp,r12 + .set .Lpic_gp, 12 + .else + .set .Lpic_gp, 1 + .endif + .elseif !.Lpic_gp + .set .Lpic_gp, 12 + .endifSetting .Lpic_gp here will cause the CONFIG_PIC segment below to try to .unreq gp. I think it works if you move this block for setting .Lpic_gp to the end of the macro.yes, the another problem is that it won't register the r12/gp aliasThen we also need to add #if CONFIG_PIC && defined(__ELF__) around the .unreq in endfunc.yes, although gas doesn't complain about unregistering an unregistered alias
Even more strange - it does for me, like this:
Error: unknown register alias 'gp'
(with gnu binutils 2.26.1)
With all those changes in place, I think it works as intended... It's pretty big and intrusive though.I wonder if it would be better to just warn if rd=r12 and gp is blank and only error if rd and gp are equal. That's simple enough not to get wrong and still catches most problems. And movrelx is not used that often that it makes sense to try to catch every wrong use with complex .if statements in the macro.
Hmm, yes, that would probably be sanest.Although, if you're in the case that would get a warning instead of an error, you can't get rid of the warning unless you actually make it reload the GOT by manually specifying gp again.
This sure is getting way more complicated than I had intended, and is taking way too much attention given how small the issue is, so I'd be completely ok with just dropping it all.
// Martin _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
