diff options
author | Geza Lore <gezalore@gmail.com> | 2016-01-18 00:21:51 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2016-01-23 20:46:28 +0100 |
commit | cc602061ee860b041013397e27a036b85cd87b09 (patch) | |
tree | 61d6c76ea3ffc687a70cae4ca57471ef145eef42 | |
parent | 002c47798da0c43a053822c8041144798d49ed84 (diff) | |
download | ffmpeg-cc602061ee860b041013397e27a036b85cd87b09.tar.gz |
x86inc: Add debug symbols indicating sizes of compiled functions
Some debuggers/profilers use this metadata to determine which function a
given instruction is in; without it they get can confused by local labels
(if you haven't stripped those). On the other hand, some tools are still
confused even with this metadata. e.g. this fixes `gdb`, but not `perf`.
Currently only implemented for ELF.
Signed-off-by: Anton Khirnov <anton@khirnov.net>
-rw-r--r-- | libavcodec/x86/proresdsp.asm | 2 | ||||
-rw-r--r-- | libavutil/x86/x86inc.asm | 23 | ||||
-rw-r--r-- | tests/checkasm/x86/checkasm.asm | 8 |
3 files changed, 28 insertions, 5 deletions
diff --git a/libavcodec/x86/proresdsp.asm b/libavcodec/x86/proresdsp.asm index a0e97b3951..5a329cb898 100644 --- a/libavcodec/x86/proresdsp.asm +++ b/libavcodec/x86/proresdsp.asm @@ -54,7 +54,7 @@ cextern pw_8 cextern pw_512 cextern pw_1019 -section .text align=16 +SECTION .text ; interleave data while maintaining source ; %1=type, %2=dstlo, %3=dsthi, %4=src, %5=interleave diff --git a/libavutil/x86/x86inc.asm b/libavutil/x86/x86inc.asm index 8a74830a20..20ef7b8a19 100644 --- a/libavutil/x86/x86inc.asm +++ b/libavutil/x86/x86inc.asm @@ -634,6 +634,7 @@ DECLARE_ARG 7, 8, 9, 10, 11, 12, 13, 14 %else rep ret %endif + annotate_function_size %endmacro %define last_branch_adr $$ @@ -642,6 +643,7 @@ DECLARE_ARG 7, 8, 9, 10, 11, 12, 13, 14 times ((last_branch_adr-$)>>31)+1 rep ; times 1 iff $ == last_branch_adr. %endif ret + annotate_function_size %endmacro %macro BRANCH_INSTR 0-* @@ -666,6 +668,7 @@ BRANCH_INSTR jz, je, jnz, jne, jl, jle, jnl, jnle, jg, jge, jng, jnge, ja, jae, %elif %2 jmp %1 %endif + annotate_function_size %endmacro ;============================================================================= @@ -687,6 +690,7 @@ BRANCH_INSTR jz, je, jnz, jne, jl, jle, jnl, jnle, jg, jge, jng, jnge, ja, jae, cglobal_internal 0, %1 %+ SUFFIX, %2 %endmacro %macro cglobal_internal 2-3+ + annotate_function_size %if %1 %xdefine %%FUNCTION_PREFIX private_prefix %xdefine %%VISIBILITY hidden @@ -700,6 +704,7 @@ BRANCH_INSTR jz, je, jnz, jne, jl, jle, jnl, jnle, jg, jge, jng, jnge, ja, jae, CAT_XDEFINE cglobaled_, %2, 1 %endif %xdefine current_function %2 + %xdefine current_function_section __SECT__ %if FORMAT_ELF global %2:function %%VISIBILITY %else @@ -748,6 +753,24 @@ BRANCH_INSTR jz, je, jnz, jne, jl, jle, jnl, jnle, jg, jge, jng, jnge, ja, jae, [SECTION .note.GNU-stack noalloc noexec nowrite progbits] %endif +; Tell debuggers how large the function was. +; This may be invoked multiple times per function; we rely on later instances overriding earlier ones. +; This is invoked by RET and similar macros, and also cglobal does it for the previous function, +; but if the last function in a source file doesn't use any of the standard macros for its epilogue, +; then its size might be unspecified. +%macro annotate_function_size 0 + %ifdef __YASM_VER__ + %ifdef current_function + %if FORMAT_ELF + current_function_section + %%ecf equ $ + size current_function %%ecf - current_function + __SECT__ + %endif + %endif + %endif +%endmacro + ; cpuflags %assign cpuflags_mmx (1<<0) diff --git a/tests/checkasm/x86/checkasm.asm b/tests/checkasm/x86/checkasm.asm index 52d10aec5c..55212fc24b 100644 --- a/tests/checkasm/x86/checkasm.asm +++ b/tests/checkasm/x86/checkasm.asm @@ -66,14 +66,14 @@ cextern fail_func ;----------------------------------------------------------------------------- cglobal stack_clobber, 1,2 ; Clobber the stack with junk below the stack pointer - %define size (max_args+6)*8 - SUB rsp, size - mov r1, size-8 + %define argsize (max_args+6)*8 + SUB rsp, argsize + mov r1, argsize-8 .loop: mov [rsp+r1], r0 sub r1, 8 jge .loop - ADD rsp, size + ADD rsp, argsize RET %if WIN64 |