User forums > Embedded development

Looking for example of "Post-build steps"

<< < (6/8) > >>

Pavel_47:

--- Quote from: christobal on December 04, 2016, 07:48:27 pm ---That wouldn't be my preferred solution.
If you want assembly files for all compiled modules, just use the GCC compiler switch -save-temps and get rid of the post-build step.

--- End quote ---

I've tried -save-temps for a quite simple source file (please see the code below)

--- Code: ---short checksum_v1(int *data);
int main (void) {
    int data[64];
    int checksum = checksum_v1(data);
return 0;
}

short checksum_v1(int *data)
{
    unsigned int i;
    int sum = 0;
    for (i = 0; i < 64; i++)
    {
        sum += *(data++);
    }
    return (short)sum;
}


#ifndef __NO_SYSTEM_INIT
void SystemInit()
{}
#endif

void _exit(int status)
{
}
--- End code ---


Here is output of arm-none-eabi-objdump command (file main.asm, 616 bytes):

--- Code: ---default\src\main.o:     file format elf32-littlearm


Disassembly of section .text:

00000000 <checksum_v1>:
   0: e3a03000 mov r3, #0
   4: e2801c01 add r1, r0, #256 ; 0x100
   8: e4902004 ldr r2, [r0], #4
   c: e1510000 cmp r1, r0
  10: e0833002 add r3, r3, r2
  14: 1afffffb bne 8 <checksum_v1+0x8>
  18: e1a00803 lsl r0, r3, #16
  1c: e1a00840 asr r0, r0, #16
  20: e12fff1e bx lr

00000024 <SystemInit>:
  24: e12fff1e bx lr

00000028 <_exit>:
  28: e12fff1e bx lr

Disassembly of section .text.startup:

00000000 <main>:
   0: e3a00000 mov r0, #0
   4: e12fff1e bx lr
--- End code ---

And here is the result of adding of -save-temps compiler option (file main.s 9645 bytes).

--- Code: --- .cpu arm7tdmi
.fpu softvfp
.eabi_attribute 20, 1
.eabi_attribute 21, 1
.eabi_attribute 23, 3
.eabi_attribute 24, 1
.eabi_attribute 25, 1
.eabi_attribute 26, 1
.eabi_attribute 30, 2
.eabi_attribute 34, 0
.eabi_attribute 18, 4
.arm
.syntax divided
.file "main.c"
.text
.Ltext0:
.cfi_sections .debug_frame
.section .text.startup,"ax",%progbits
.align 2
.global main
.type main, %function
main:
.LFB0:
.file 1 "src\\main.c"
.loc 1 2 0
.cfi_startproc
@ Function supports interworking.
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
@ link register save eliminated.
.LVL0:
.loc 1 6 0
mov r0, #0
bx lr
.cfi_endproc
.LFE0:
.size main, .-main
.text
.align 2
.global checksum_v1
.type checksum_v1, %function
checksum_v1:
.LFB1:
.loc 1 9 0
.cfi_startproc
@ Function supports interworking.
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
@ link register save eliminated.
.LVL1:
.loc 1 11 0
mov r3, #0
add r1, r0, #256
.LVL2:
.L3:
.loc 1 14 0 discriminator 3
ldr r2, [r0], #4
.LVL3:
.loc 1 12 0 discriminator 3
cmp r1, r0
.loc 1 14 0 discriminator 3
add r3, r3, r2
.LVL4:
.loc 1 12 0 discriminator 3
bne .L3
.loc 1 16 0
mov r0, r3, asl #16
.LVL5:
.loc 1 17 0
mov r0, r0, asr #16
bx lr
.cfi_endproc
.LFE1:
.size checksum_v1, .-checksum_v1
.align 2
.global SystemInit
.type SystemInit, %function
SystemInit:
.LFB2:
.loc 1 22 0
.cfi_startproc
@ Function supports interworking.
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
@ link register save eliminated.
bx lr
.cfi_endproc
.LFE2:
.size SystemInit, .-SystemInit
.align 2
.global _exit
.type _exit, %function
_exit:
.LFB3:
.loc 1 26 0
.cfi_startproc
@ Function supports interworking.
@ Volatile: function does not return.
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
@ link register save eliminated.
.LVL6:
.loc 1 27 0
bx lr
.cfi_endproc
.LFE3:
.size _exit, .-_exit
.Letext0:
.section .debug_info,"",%progbits
.Ldebug_info0:
.4byte 0x114
.2byte 0x4
.4byte .Ldebug_abbrev0
.byte 0x4
.uleb128 0x1
.4byte .LASF4
.byte 0xc
.4byte .LASF5
.4byte .LASF6
.4byte .Ldebug_ranges0+0
.4byte 0
.4byte .Ldebug_line0
.uleb128 0x2
.4byte .LASF7
.byte 0x1
.byte 0x8
.4byte 0x55
.byte 0x1
.4byte 0x55
.uleb128 0x3
.4byte .LASF2
.byte 0x1
.byte 0x8
.4byte 0x5c
.uleb128 0x4
.ascii "i\000"
.byte 0x1
.byte 0xa
.4byte 0x69
.uleb128 0x4
.ascii "sum\000"
.byte 0x1
.byte 0xb
.4byte 0x62
.byte 0
.uleb128 0x5
.byte 0x2
.byte 0x5
.4byte .LASF0
.uleb128 0x6
.byte 0x4
.4byte 0x62
.uleb128 0x7
.byte 0x4
.byte 0x5
.ascii "int\000"
.uleb128 0x5
.byte 0x4
.byte 0x7
.4byte .LASF1
.uleb128 0x8
.4byte .LASF8
.byte 0x1
.byte 0x2
.4byte 0x62
.4byte .LFB0
.4byte .LFE0-.LFB0
.uleb128 0x1
.byte 0x9c
.4byte 0xa1
.uleb128 0x9
.4byte .LASF2
.byte 0x1
.byte 0x3
.4byte 0xa1
.uleb128 0xa
.4byte .LASF9
.byte 0x1
.byte 0x4
.4byte 0x62
.byte 0
.byte 0
.uleb128 0xb
.4byte 0x62
.4byte 0xb1
.uleb128 0xc
.4byte 0xb1
.byte 0x3f
.byte 0
.uleb128 0x5
.byte 0x4
.byte 0x7
.4byte .LASF3
.uleb128 0xd
.4byte 0x25
.4byte .LFB1
.4byte .LFE1-.LFB1
.uleb128 0x1
.byte 0x9c
.4byte 0xe7
.uleb128 0xe
.4byte 0x35
.4byte .LLST0
.uleb128 0xf
.4byte 0x40
.4byte .LLST1
.uleb128 0xf
.4byte 0x49
.4byte .LLST2
.byte 0
.uleb128 0x10
.4byte .LASF10
.byte 0x1
.byte 0x15
.4byte .LFB2
.4byte .LFE2-.LFB2
.uleb128 0x1
.byte 0x9c
.uleb128 0x11
.4byte .LASF11
.byte 0x1
.byte 0x19
.4byte .LFB3
.4byte .LFE3-.LFB3
.uleb128 0x1
.byte 0x9c
.uleb128 0x12
.4byte .LASF12
.byte 0x1
.byte 0x19
.4byte 0x62
.uleb128 0x1
.byte 0x50
.byte 0
.byte 0
.section .debug_abbrev,"",%progbits
.Ldebug_abbrev0:
.uleb128 0x1
.uleb128 0x11
.byte 0x1
.uleb128 0x25
.uleb128 0xe
.uleb128 0x13
.uleb128 0xb
.uleb128 0x3
.uleb128 0xe
.uleb128 0x1b
.uleb128 0xe
.uleb128 0x55
.uleb128 0x17
.uleb128 0x11
.uleb128 0x1
.uleb128 0x10
.uleb128 0x17
.byte 0
.byte 0
.uleb128 0x2
.uleb128 0x2e
.byte 0x1
.uleb128 0x3f
.uleb128 0x19
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x27
.uleb128 0x19
.uleb128 0x49
.uleb128 0x13
.uleb128 0x20
.uleb128 0xb
.uleb128 0x1
.uleb128 0x13
.byte 0
.byte 0
.uleb128 0x3
.uleb128 0x5
.byte 0
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.byte 0
.byte 0
.uleb128 0x4
.uleb128 0x34
.byte 0
.uleb128 0x3
.uleb128 0x8
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.byte 0
.byte 0
.uleb128 0x5
.uleb128 0x24
.byte 0
.uleb128 0xb
.uleb128 0xb
.uleb128 0x3e
.uleb128 0xb
.uleb128 0x3
.uleb128 0xe
.byte 0
.byte 0
.uleb128 0x6
.uleb128 0xf
.byte 0
.uleb128 0xb
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.byte 0
.byte 0
.uleb128 0x7
.uleb128 0x24
.byte 0
.uleb128 0xb
.uleb128 0xb
.uleb128 0x3e
.uleb128 0xb
.uleb128 0x3
.uleb128 0x8
.byte 0
.byte 0
.uleb128 0x8
.uleb128 0x2e
.byte 0x1
.uleb128 0x3f
.uleb128 0x19
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x27
.uleb128 0x19
.uleb128 0x49
.uleb128 0x13
.uleb128 0x11
.uleb128 0x1
.uleb128 0x12
.uleb128 0x6
.uleb128 0x40
.uleb128 0x18
.uleb128 0x2117
.uleb128 0x19
.uleb128 0x1
.uleb128 0x13
.byte 0
.byte 0
.uleb128 0x9
.uleb128 0x34
.byte 0
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.byte 0
.byte 0
.uleb128 0xa
.uleb128 0x34
.byte 0
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.uleb128 0x1c
.uleb128 0xb
.byte 0
.byte 0
.uleb128 0xb
.uleb128 0x1
.byte 0x1
.uleb128 0x49
.uleb128 0x13
.uleb128 0x1
.uleb128 0x13
.byte 0
.byte 0
.uleb128 0xc
.uleb128 0x21
.byte 0
.uleb128 0x49
.uleb128 0x13
.uleb128 0x2f
.uleb128 0xb
.byte 0
.byte 0
.uleb128 0xd
.uleb128 0x2e
.byte 0x1
.uleb128 0x31
.uleb128 0x13
.uleb128 0x11
.uleb128 0x1
.uleb128 0x12
.uleb128 0x6
.uleb128 0x40
.uleb128 0x18
.uleb128 0x2117
.uleb128 0x19
.uleb128 0x1
.uleb128 0x13
.byte 0
.byte 0
.uleb128 0xe
.uleb128 0x5
.byte 0
.uleb128 0x31
.uleb128 0x13
.uleb128 0x2
.uleb128 0x17
.byte 0
.byte 0
.uleb128 0xf
.uleb128 0x34
.byte 0
.uleb128 0x31
.uleb128 0x13
.uleb128 0x2
.uleb128 0x17
.byte 0
.byte 0
.uleb128 0x10
.uleb128 0x2e
.byte 0
.uleb128 0x3f
.uleb128 0x19
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x11
.uleb128 0x1
.uleb128 0x12
.uleb128 0x6
.uleb128 0x40
.uleb128 0x18
.uleb128 0x2117
.uleb128 0x19
.byte 0
.byte 0
.uleb128 0x11
.uleb128 0x2e
.byte 0x1
.uleb128 0x3f
.uleb128 0x19
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x27
.uleb128 0x19
.uleb128 0x87
.uleb128 0x19
.uleb128 0x11
.uleb128 0x1
.uleb128 0x12
.uleb128 0x6
.uleb128 0x40
.uleb128 0x18
.uleb128 0x2117
.uleb128 0x19
.byte 0
.byte 0
.uleb128 0x12
.uleb128 0x5
.byte 0
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.uleb128 0x2
.uleb128 0x18
.byte 0
.byte 0
.byte 0
.section .debug_loc,"",%progbits
.Ldebug_loc0:
.LLST0:
.4byte .LVL1
.4byte .LVL3
.2byte 0x1
.byte 0x50
.4byte .LVL3
.4byte .LVL4
.2byte 0x3
.byte 0x70
.sleb128 -4
.byte 0x9f
.4byte .LVL4
.4byte .LVL5
.2byte 0x1
.byte 0x50
.4byte 0
.4byte 0
.LLST1:
.4byte .LVL1
.4byte .LVL2
.2byte 0x2
.byte 0x30
.byte 0x9f
.4byte 0
.4byte 0
.LLST2:
.4byte .LVL1
.4byte .LVL2
.2byte 0x2
.byte 0x30
.byte 0x9f
.4byte .LVL2
.4byte .LFE1
.2byte 0x1
.byte 0x53
.4byte 0
.4byte 0
.section .debug_aranges,"",%progbits
.4byte 0x24
.2byte 0x2
.4byte .Ldebug_info0
.byte 0x4
.byte 0
.2byte 0
.2byte 0
.4byte .Ltext0
.4byte .Letext0-.Ltext0
.4byte .LFB0
.4byte .LFE0-.LFB0
.4byte 0
.4byte 0
.section .debug_ranges,"",%progbits
.Ldebug_ranges0:
.4byte .Ltext0
.4byte .Letext0
.4byte .LFB0
.4byte .LFE0
.4byte 0
.4byte 0
.section .debug_line,"",%progbits
.Ldebug_line0:
.section .debug_str,"MS",%progbits,1
.LASF11:
.ascii "_exit\000"
.LASF1:
.ascii "unsigned int\000"
.LASF7:
.ascii "checksum_v1\000"
.LASF12:
.ascii "status\000"
.LASF10:
.ascii "SystemInit\000"
.LASF0:
.ascii "short int\000"
.LASF9:
.ascii "checksum\000"
.LASF3:
.ascii "sizetype\000"
.LASF8:
.ascii "main\000"
.LASF5:
.ascii "src\\main.c\000"
.LASF2:
.ascii "data\000"
.LASF6:
.ascii "C:\\\\Users\\\\Pavel\\\\Documents\\\\proj_ARM\\\\pr"
.ascii "oj1\000"
.LASF4:
.ascii "GNU C11 5.4.1 20160919 (release) [ARM/embedded-5-br"
.ascii "anch revision 240496] -mcpu=arm7tdmi -g -g -O2 -fno"
.ascii "-common\000"
.ident "GCC: (GNU Tools for ARM Embedded Processors) 5.4.1 20160919 (release) [ARM/embedded-5-branch revision 240496]"

--- End code ---

While the content of main.asm (output of arm-none-eabi-objdump) is clear and comprehensible, the content of main.s (generated by compiler after adding -save-temps option) is bulky, intricate, difficult to discern the code, related to functions in source file.

christobal:
main.s is the interim assembly file that has been generated by the compiler. It contains a lot of information needed by the assembler (e.g. that there is a global symbol named "main", which is a function that has a 2 Byte alignment requirement).
main.asm is just a disassembly file that has been derived from the object file (generated by the assembler).

If you want a full disassembly of your application, maybe you can disassemble the elf file with objdump instead of each object file on it's own?

Pavel_47:

--- Quote from: christobal on December 05, 2016, 02:30:12 pm ---main.s is the interim assembly file that has been generated by the compiler. It contains a lot of information needed by the assembler (e.g. that there is a global symbol named "main", which is a function that has a 2 Byte alignment requirement).
main.asm is just a disassembly file that has been derived from the object file (generated by the assembler).

If you want a full disassembly of your application, maybe you can disassemble the elf file with objdump instead of each object file on it's own?

--- End quote ---
For the moment I don't need to disassembly application, but rather file by file ... to estimate the efficiency of compiled code.
For this purposes the objdump matches perfectly what I need.
The only problem to resolve (before closing this thread) is to find a solution how to process multiple files using objdump.
BlueHazzard suggested interesting approach (based on squirrel scripting), but there are still issues to resolve.

Pavel_47:
Strange "sticky" issue in post-build step is suddenly revealed.
Here is my post-build command (note that input file is main.o):


--- Code: ---cmd /C arm-none-eabi-objdump -d $(TARGET_OUTPUT_DIR)src\main.o > $(TARGET_OUTPUT_DIR)src\main.asm
--- End code ---

And here is Build log:

--- Code: ---Running project pre-build steps
cmd /C echo h\evaluator7t.hld\target.ldsrc\main.csrc\startup_ARMCM7.Ssrc\vectors.S
h\evaluator7t.hld\target.ldsrc\main.csrc\startup_ARMCM7.Ssrc\vectors.S

-------------- Build: default in proj1 (compiler: GNU GCC Compiler for ARM)---------------

arm-none-eabi-gcc.exe -mcpu=arm7tdmi -O2 -Wall -g -fno-common -save-temps -DARM_EVAL7T -D__NO_CTOR_DTOR_SUPPORT__ -g -Isrc -Ih -c src\main.c -o default\src\main.o
src\main.c: In function 'main':
src\main.c:3:11: warning: unused variable 'a' [-Wunused-variable]
     short a = add_v1(3, 4);
           ^
src\main.c: In function '_exit':
src\main.c:20:1: warning: 'noreturn' function does return
 }
 ^
arm-none-eabi-g++.exe -mcpu=arm7tdmi -O2 -Wall -g -fno-common -save-temps -DARM_EVAL7T -D__NO_CTOR_DTOR_SUPPORT__ -g -Isrc -Ih -c src\startup_ARMCM7.S -o default\src\startup_ARMCM7.o
src\startup_ARMCM7.S:7:1: warning: "/*" within comment [-Wcomment]
 /* Copyright (c) 2011 - 2014 ARM LIMITED
 ^
arm-none-eabi-g++.exe -L"C:\Program Files (x86)\GNU Tools ARM Embedded\5.4 2016q3\lib\gcc\arm-none-eabi\5.4.1" -o default\proj1.elf default\src\main.o default\src\startup_ARMCM7.o  -s -Wl,-Map,map.txt -mtune=arm7tdmi -T ld/gcc.ld 
Output file is default\proj1.elf with size 132.65 KB
Running target post-build steps
arm-none-eabi-objdump -d main1.o > main1.asm
arm-none-eabi-objdump: 'main1.o': No such file
arm-none-eabi-objdump: Warning: '>' is not an ordinary file
arm-none-eabi-objdump: 'main1.asm': No such file
Process terminated with status 1 (0 minute(s), 0 second(s))
0 error(s), 4 warning(s) (0 minute(s), 0 second(s))

--- End code ---

As you can state from the log, the input file for arm-none-eabi-objdump is no more main.o, but main1.o.
Quite strange ... Ok, I used also main1.o in post-build in the past, but now the input is main.o, not main1.o ... moreover main1.c was removed from project and project was cleaned.

Any comments ?

christobal:
Open the project file (.cbp) with a text editor and search for "main1". I guess there are some "remnants" of your tests in the post-build step configuration.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version