汇编指令 定义一个函数入口的宏的解释

经常,我们在看代码的时候对一些汇编的directives不明白。那么以下面为例,

#define FUNCTION_THUMB_ENTRY(name) \
  .thumb; \
  .thumb_func; \
  .align 2; \
  .globl name; \
  .type name, %function; \
  name:

The .thumb_func directive tells the assembler that the next symbol will point to Arm THUMB code, so ...

                    .thumb_func

.align will align the location counter on a (1 << argument) byte boundary

The .type directive allows you to tell the assembler what type a symbol is. Most of the time we just use %functionand %object.

                    .type               hexTable,%object

...or...

                    .type               qsort,%function


有时候还有 

.size

The .size directive can be used to tell the assembler how much space the data that a symbol points to is using.

For instance...

                    .size               qsort,.-qsort

... will calculate the total size in bytes of the function 'qsort', so that the linker can exclude the function if it's unused.

Note: When used inside an expression, the dot '.' means the current value of the location counter.

这是个很好的汇编查询网站

https://community.arm.com/processors/b/blog/posts/useful-assembler-directives-and-macros-for-the-gnu-assembler



你可能感兴趣的:(ARM)