Search code examples
assemblyllvmgnu-assemblerpowerpc

Does the .size directive here do anything?


I'm currently trying to cross-compile musl 1.1.18 on an x86-64 host for a powerpc64le target using LLVM 3.7.1. It's failing to compile on the file/code shown below with error: unexpected token in '.end' directive. That's not my question.

From src/internal/powerpc64/syscall.s:

    .global __syscall
    .hidden __syscall
    .type   __syscall,@function
__syscall:
    mr      0, 3                  # Save the system call number
    mr      3, 4                  # Shift the arguments: arg1
    mr      4, 5                  # arg2
    mr      5, 6                  # arg3
    mr      6, 7                  # arg4
    mr      7, 8                  # arg5
    mr      8, 9                  # arg6
    sc
    bnslr+       # return if not summary overflow
    neg     3, 3 # otherwise error: return negated value.
    blr
    .end    __syscall
    .size   __syscall, .-__syscall

My question is: does the .size directive here do anything? According to the gas documentation, the .end directive signifies the end of the file and nothing further will be processed. Am I missing something here?


Solution

  • This seems to be an undocumented feature of the GNU assembler. Apparently it is used to emit debug information in ECOFF format. See gas/config/obj-ecoff.c:259 and gas/ecoff.c:2981

    /* ECOFF specific debugging information.  */
    { "aent",     ecoff_directive_ent,    1 },
    { "begin",    ecoff_directive_begin,  0 },
    { "bend",     ecoff_directive_bend,   0 },
    { "end",      ecoff_directive_end,    0 },