[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Linker script patch to handle __flashN [Was: Handling

From: Georg-Johann Lay
Subject: Re: [avr-gcc-list] Linker script patch to handle __flashN [Was: Handling __flash1 and .trampolines]
Date: Thu, 13 Dec 2012 14:26:33 +0100
User-agent: Thunderbird (Windows/20100228)

Erik Christiansen schrieb:

Here are two test cases based on one source code example compared with
Johann's requirements for the script behaviour.

Here is more torture.  Assemble with, e.g.

$ avr-gcc flash.sx -o flash.elf -DSTUBS=10 -DP1=0x200 -DTEXT=0x20000 -mmcu=atmega2560 -Wl,-Map,flash.map
$ avr-objdump -d -j .text -j .data flash.elf > flash.lst

Following macros are recognized:

P0, P1, P2, P3 : bytes of data in respective .progmem
TEXT, LOWTEXT  : bytes added to .text, .lowtext
STUBS          : generate code that might need STUBS stubs

TEXT is not the complete .text site because startup code and STUBS and more like _exit will add.

Notice that most users let the driver (avr-gcc) call the linker to supply it with the right options and multilibs.

The driver knows how to handle -T, see the output with -v

#ifndef TEXT
#define TEXT 0

#ifndef LOWTEXT
#define LOWTEXT 0

#ifndef STUBS
#define STUBS 0

#ifndef P0
#define P0 0

#ifndef P1
#define P1 0

#ifndef P2
#define P2 0

#ifndef P3
#define P3 0

.macro Flash n num
    .section .progmem\n\().data.foo\n\(),"a",@progbits
    .global flash\n\()_start
    .type flash\n\()_start,@object
        .fill \num
    .size flash\n\()_start, .-flash\n\()_start

Flash  , P0
Flash 1, P1
Flash 2, P2
Flash 3, P3

.global main
.rept TEXT / 2
.rept STUBS
    ldi r16, lo8(gs(0b))
    ldi r17, hi8(gs(0b))
.size main, .-main

.section .lowtext,"ax",@progbits
.global lowfunc
.rept LOWTEXT / 2
.size lowfunc, .-lowfunc

reply via email to

[Prev in Thread] Current Thread [Next in Thread]