GNU assembler .macro directive does not expand fully

Asked by Prakash K Balasubramanian

How can I get the .macro directive to faithfully reproduce desired contents?

I have the following macro defined:

      .macro Insert_Function Routine
        .weak \Routine
        .type \Routine, %function
        \Routine :
        B .
       .size \Routine, . - \Routine
      .endm

And it in the same file is used as:

    Insert_Function NMI_Handler
    /* ================= */
    Insert_Function HardFault_Handler
    /* ================= */

The following is the output extracted from the list file:

    Insert_Function NMI_Handler
10001172: e7fe b.n 10001172 <NMI_Handler>

10001174 <HardFault_Handler>:
/* ================== */
    Insert_Function HardFault_Handler
10001174: e7fe b.n 10001174 <HardFault_Handler>

10001176 <SVC_Handler>:
/* ================== */

There are two problems with this listing.
1. The .weak and .type attributes are not reproduced
2. The succeeding label is inexplicably considered alongside the current label space.
For example, HardFault_Handler label is seen in NMI_Handler listing while SVC_Handler label can be seen in HardFault_Handler listing. Although addresses assigned to the labels are correct and non-overlapping

Question information

Language:
English Edit question
Status:
Solved
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Solved by:
Joey Ye
Solved:
Last query:
Last reply:
Revision history for this message
Best Joey Ye (jinyun-ye) said :
#1

1. .weak and .type doesn't show in list file. That only impact symbol attribute. If you arm-none-eabi-objdump -t your.o, you should see
0000002a w F .text 00000002 HardFault_Handler

w is weak, F is function

2. It is expected. In ASM there is no such thing as "label scope". All symbols are treated flatly and equally.

Revision history for this message
Prakash K Balasubramanian (prakash-balasubramanian) said :
#2

Thanks Joey Ye, that solved my question.