This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
[patch] avr-binutils changes
- To: denisc at overta dot ru
- Subject: [patch] avr-binutils changes
- From: Marek Michalkiewicz <marekm at linux dot org dot pl>
- Date: Mon, 26 Jun 2000 20:15:14 +0200 (CEST)
- CC: binutils at sourceware dot cygnus dot com, avr at fov dot uni-mb dot si
Below is a patch for binutils on AVR target. It is quite big -
sorry about that, but (as with my recent avr-gcc patch, applied
now - big thanks, Denis!) there are more changes to come...
Changes in this patch include:
- support for more new MCU types, replace at94k{10,20,40} with
just at94k (the AVR core is the same, only the FPGA differs).
New avr5 machine type, and bug fix for compatible().
- simplified 8K wrap handling: no separate flag, instead simply
no wrap for >8K devices. Also no need to add +/-4096 to the
jump address that is bitwise-ANDed with 0xFFF later anyway.
(To do: the assembler should mark any rjmp/rcall known to wrap
with a special relocation, the linker should report an error if
it sees this in the object file when linking for >8K devices.
Just a suggestion, not sure if I can do it myself...)
- support for future avr-gcc changes (ASM_SPEC will pass -mmcu=...
so there will be no need to pass it separately via -Wa,-mmcu=...
when preprocessing asm source), avoid "redefinition of mcu type"
gas error messages when compiling C code.
- "espm" instruction removed, following recent AVR documentation
update (http://www.atmel.com/atmel/acrobat/databook.pdf).
Other opcodes for devices that don't exist yet (eicall, eijmp)
moved to the end of the table - just to make it clear that the
comment above refers only to these two opcodes.
I have tried to maintain backward compatibility, so there is no need
to upgrade avr-gcc immediately. But some of my future avr-gcc patches
may require avr-binutils with this patch applied.
The avr4 bfd machine type is renamed to avr5 for consistency.
Now the bfd types are as follows:
- avr1: <=2K, no RAM, assembler only
- avr2: <=8K, old core
- avr3: >8K, old core
- avr4: <=8K, new core (new)
- avr5: >8K, new core (used to be avr4)
(the order is now so that lower numbered machines are subsets of
higher numbered ones, except avr3/avr4).
Hopefully this will not cause too many problems, as no avr4 or avr5
devices are really available yet (without NDA that is). I haven't
yet added new ld emulations and scripts for all the new devices.
(Maybe we need just one emulation for each avr[1-5] machine type,
and possibly the "INCLUDE memory.x" trick from the 68hc11 port?)
I know bfd/bfd-in2.h should be regenerated, but I had some trouble
with it so I patched it instead (just one line added).
As usual, please review. Suggestions are always welcome.
Thanks, and keep up the good work!
Marek
bfd/ChangeLog:
2000-06-26 Marek Michalkiewicz <marekm@linux.org.pl>
* archures.c (bfd_mach_avr5): Define.
* bfd-in2.h (bfd_mach_avr5): Define.
* cpu-avr.c (arch_info_struct): Rename bfd_mach_avr4 to
bfd_mach_avr5, add bfd_mach_avr4. Update comments.
(compatible): Update comment. Add missing test.
* elf32-avr.c (avr_final_link_relocate): Support 8K wrap
for avr2 and avr4. Simplify 8K wrap code.
(bfd_elf_avr_final_write_processing): Recognize bfd_mach_avr5.
(elf32_avr_object_p): Recognize E_AVR_MACH_AVR5.
gas/ChangeLog:
2000-06-26 Marek Michalkiewicz <marekm@linux.org.pl>
* config/tc-avr.c (mcu_types): Rename avr4 to avr5, add avr4.
Add more MCU types for avr4 and avr5. Replace at94k{10,20,40}
with just at94k. Change AVR_ISA_85xx back to AVR_ISA_2xxx.
(md_show_usage): Update usage message.
(md_parse_option): Allow redefinition of MCU type within the
same avr[1-5] bfd machine type. Show both old and new MCU type
in the error message.
(md_apply_fix3): Support 8K wrap if AVR_ISA_MEGA is not set.
Simplify 8K wrap code.
include/elf/ChangeLog:
2000-06-26 Marek Michalkiewicz <marekm@linux.org.pl>
* avr.h (E_AVR_MACH_AVR5): Define.
include/opcode/ChangeLog:
2000-06-26 Marek Michalkiewicz <marekm@linux.org.pl>
* avr.h (AVR_ISA_WRAP): Remove, now assumed if not AVR_ISA_MEGA.
(AVR_ISA_ESPM): Remove, because ESPM removed in databook update.
(AVR_ISA_85xx): Remove, all uses changed back to AVR_ISA_2xxx.
(AVR_ISA_M83): Define for ATmega83, ATmega85.
(espm): Remove, because ESPM removed in databook update.
(eicall, eijmp): Move to the end of opcode table.
ld/ChangeLog:
2000-06-26 Marek Michalkiewicz <marekm@linux.org.pl>
* emulparams/avrmega161.sh (ARCH): Change to avr:5.
diff -Nrc3p orig/src/bfd/archures.c src/bfd/archures.c
*** orig/src/bfd/archures.c Tue Jun 20 07:59:05 2000
--- src/bfd/archures.c Mon Jun 26 11:28:07 2000
*************** DESCRIPTION
*** 229,234 ****
--- 229,235 ----
.#define bfd_mach_avr2 2
.#define bfd_mach_avr3 3
.#define bfd_mach_avr4 4
+ .#define bfd_mach_avr5 5
. bfd_arch_last
. };
diff -Nrc3p orig/src/bfd/bfd-in2.h src/bfd/bfd-in2.h
*** orig/src/bfd/bfd-in2.h Tue Jun 20 07:59:08 2000
--- src/bfd/bfd-in2.h Mon Jun 26 11:30:05 2000
*************** enum bfd_architecture
*** 1468,1473 ****
--- 1468,1474 ----
#define bfd_mach_avr2 2
#define bfd_mach_avr3 3
#define bfd_mach_avr4 4
+ #define bfd_mach_avr5 5
bfd_arch_last
};
diff -Nrc3p orig/src/bfd/cpu-avr.c src/bfd/cpu-avr.c
*** orig/src/bfd/cpu-avr.c Thu Jun 8 08:11:27 2000
--- src/bfd/cpu-avr.c Mon Jun 26 11:36:01 2000
*************** static const bfd_arch_info_type *compati
*** 45,61 ****
static const bfd_arch_info_type arch_info_struct[] =
{
! /* AT90S1200 */
N (16, bfd_mach_avr1, "avr:1", false, & arch_info_struct[1]),
! /* AT90S2xxx, AT90S4xxx, AT90S81xx, ATtiny22 */
N (16, bfd_mach_avr2, "avr:2", false, & arch_info_struct[2]),
/* ATmega103, ATmega603 */
N (22, bfd_mach_avr3, "avr:3", false, & arch_info_struct[3]),
! /* ATmega161 */
! N (16, bfd_mach_avr4, "avr:4", false, NULL)
};
const bfd_arch_info_type bfd_avr_arch =
--- 45,64 ----
static const bfd_arch_info_type arch_info_struct[] =
{
! /* AT90S1200, ATtiny1x, ATtiny28 */
N (16, bfd_mach_avr1, "avr:1", false, & arch_info_struct[1]),
! /* AT90S2xxx, AT90S4xxx, AT90S8xxx, ATtiny22 */
N (16, bfd_mach_avr2, "avr:2", false, & arch_info_struct[2]),
/* ATmega103, ATmega603 */
N (22, bfd_mach_avr3, "avr:3", false, & arch_info_struct[3]),
! /* ATmega83, ATmega85 */
! N (16, bfd_mach_avr4, "avr:4", false, & arch_info_struct[4]),
!
! /* ATmega161, ATmega163, ATmega32, AT94K */
! N (22, bfd_mach_avr5, "avr:5", false, NULL)
};
const bfd_arch_info_type bfd_avr_arch =
*************** compatible (a,b)
*** 74,80 ****
if (a->arch != b->arch)
return NULL;
! /* Special case for ATmega[16]03 (avr:3) and ATmega161 (avr:4). */
if ((a->mach == 3 && b->mach == 4)
|| (a->mach == 4 && b->mach == 3))
return NULL;
--- 77,83 ----
if (a->arch != b->arch)
return NULL;
! /* Special case for ATmega[16]03 (avr:3) and ATmega83 (avr:4). */
if ((a->mach == 3 && b->mach == 4)
|| (a->mach == 4 && b->mach == 3))
return NULL;
*************** compatible (a,b)
*** 83,88 ****
--- 86,94 ----
cores. */
if (a->mach <= b->mach)
return b;
+
+ if (a->mach >= b->mach)
+ return a;
/* Never reached! */
return NULL;
diff -Nrc3p orig/src/bfd/elf32-avr.c src/bfd/elf32-avr.c
*** orig/src/bfd/elf32-avr.c Thu Jun 8 08:11:29 2000
--- src/bfd/elf32-avr.c Mon Jun 26 11:44:03 2000
*************** avr_final_link_relocate (howto, input_bf
*** 548,562 ****
if (srel < -2048 || srel > 2047)
{
/* Apply WRAPAROUND if possible. */
! if (bfd_get_mach (input_bfd) == bfd_mach_avr2)
{
! if (srel > 2047)
! srel -= 4096;
! else
! srel += 4096;
}
- else
- return bfd_reloc_overflow;
}
x = bfd_get_16 (input_bfd, contents);
--- 548,562 ----
if (srel < -2048 || srel > 2047)
{
/* Apply WRAPAROUND if possible. */
! switch (bfd_get_mach (input_bfd))
{
! case bfd_mach_avr2:
! case bfd_mach_avr4:
! break;
!
! default:
! return bfd_reloc_overflow;
}
}
x = bfd_get_16 (input_bfd, contents);
*************** bfd_elf_avr_final_write_processing (abfd
*** 899,904 ****
--- 899,907 ----
val = E_AVR_MACH_AVR4;
break;
+ case bfd_mach_avr5:
+ val = E_AVR_MACH_AVR5;
+ break;
}
elf_elfheader (abfd)->e_machine = EM_AVR;
*************** elf32_avr_object_p (abfd)
*** 933,938 ****
--- 936,945 ----
case E_AVR_MACH_AVR4:
e_set = bfd_mach_avr4;
+ break;
+
+ case E_AVR_MACH_AVR5:
+ e_set = bfd_mach_avr5;
break;
}
}
diff -Nrc3p orig/src/gas/config/tc-avr.c src/gas/config/tc-avr.c
*** orig/src/gas/config/tc-avr.c Thu Jun 8 08:11:50 2000
--- src/gas/config/tc-avr.c Mon Jun 26 12:50:11 2000
*************** struct mcu_type_s
*** 59,67 ****
static struct mcu_type_s mcu_types[] =
{
{"avr1", AVR_ISA_TINY1, bfd_mach_avr1},
! {"avr2", AVR_ISA_85xx, bfd_mach_avr2},
{"avr3", AVR_ISA_M103, bfd_mach_avr3},
! {"avr4", AVR_ISA_ALL, bfd_mach_avr4},
{"at90s1200", AVR_ISA_1200, bfd_mach_avr1},
{"attiny10", AVR_ISA_TINY1, bfd_mach_avr1},
{"attiny11", AVR_ISA_TINY1, bfd_mach_avr1},
--- 59,68 ----
static struct mcu_type_s mcu_types[] =
{
{"avr1", AVR_ISA_TINY1, bfd_mach_avr1},
! {"avr2", AVR_ISA_2xxx, bfd_mach_avr2},
{"avr3", AVR_ISA_M103, bfd_mach_avr3},
! {"avr4", AVR_ISA_M83, bfd_mach_avr4},
! {"avr5", AVR_ISA_ALL, bfd_mach_avr5},
{"at90s1200", AVR_ISA_1200, bfd_mach_avr1},
{"attiny10", AVR_ISA_TINY1, bfd_mach_avr1},
{"attiny11", AVR_ISA_TINY1, bfd_mach_avr1},
*************** static struct mcu_type_s mcu_types[] =
*** 76,90 ****
{"at90s4433", AVR_ISA_2xxx, bfd_mach_avr2},
{"at90s4414", AVR_ISA_2xxx, bfd_mach_avr2},
{"at90s4434", AVR_ISA_2xxx, bfd_mach_avr2},
! {"at90s8515", AVR_ISA_85xx, bfd_mach_avr2},
! {"at90s8535", AVR_ISA_85xx, bfd_mach_avr2},
! {"at90c8534", AVR_ISA_85xx, bfd_mach_avr2},
{"atmega603", AVR_ISA_M603, bfd_mach_avr3},
{"atmega103", AVR_ISA_M103, bfd_mach_avr3},
! {"atmega161", AVR_ISA_M161, bfd_mach_avr4},
! {"at94k10", AVR_ISA_94K, bfd_mach_avr4},
! {"at94k20", AVR_ISA_94K, bfd_mach_avr4},
! {"at94k40", AVR_ISA_94K, bfd_mach_avr4},
{NULL, 0, 0}
};
--- 77,93 ----
{"at90s4433", AVR_ISA_2xxx, bfd_mach_avr2},
{"at90s4414", AVR_ISA_2xxx, bfd_mach_avr2},
{"at90s4434", AVR_ISA_2xxx, bfd_mach_avr2},
! {"at90s8515", AVR_ISA_2xxx, bfd_mach_avr2},
! {"at90s8535", AVR_ISA_2xxx, bfd_mach_avr2},
! {"at90c8534", AVR_ISA_2xxx, bfd_mach_avr2},
{"atmega603", AVR_ISA_M603, bfd_mach_avr3},
{"atmega103", AVR_ISA_M103, bfd_mach_avr3},
! {"atmega83", AVR_ISA_M83, bfd_mach_avr4},
! {"atmega85", AVR_ISA_M83, bfd_mach_avr4},
! {"atmega161", AVR_ISA_M161, bfd_mach_avr5},
! {"atmega163", AVR_ISA_M161, bfd_mach_avr5},
! {"atmega32", AVR_ISA_M161, bfd_mach_avr5},
! {"at94k", AVR_ISA_94K, bfd_mach_avr5},
{NULL, 0, 0}
};
*************** md_show_usage (stream)
*** 204,213 ****
_ ("AVR options:\n"
" -mmcu=[avr-name] select microcontroller variant\n"
" [avr-name] can be:\n"
! " avr1 - AT90S1200\n"
! " avr2 - AT90S2xxx, AT90S4xxx, AT90S85xx, ATtiny22\n"
! " avr3 - ATmega103 or ATmega603\n"
! " avr4 - ATmega161\n"
" or immediate microcontroller name.\n"));
}
--- 207,217 ----
_ ("AVR options:\n"
" -mmcu=[avr-name] select microcontroller variant\n"
" [avr-name] can be:\n"
! " avr1 - AT90S1200, ATtiny1x, ATtiny28\n"
! " avr2 - AT90S2xxx, AT90S4xxx, AT90S8xxx, ATtiny22\n"
! " avr3 - ATmega103, ATmega603\n"
! " avr4 - ATmega83, ATmega85\n"
! " avr5 - ATmega161, ATmega163, ATmega32, AT94K\n"
" or immediate microcontroller name.\n"));
}
*************** md_parse_option (c, arg)
*** 244,253 ****
if (!mcu_types[i].name)
as_fatal (_ ("unknown MCU: %s\n"), arg);
! if (avr_mcu == &default_mcu)
avr_mcu = &mcu_types[i];
else
! as_fatal (_ ("redefinition of mcu type `%s'"), mcu_types[i].name);
return 1;
}
return 0;
--- 248,263 ----
if (!mcu_types[i].name)
as_fatal (_ ("unknown MCU: %s\n"), arg);
!
! /* It is OK to redefine mcu type within the same avr[1-5] bfd machine
! type - this for allows passing -mmcu=... via gcc ASM_SPEC as well
! as .arch ... in the asm output at the same time. */
!
! if (avr_mcu == &default_mcu || avr_mcu->mach == mcu_types[i].mach)
avr_mcu = &mcu_types[i];
else
! as_fatal (_ ("redefinition of mcu type `%s' to `%s'"),
! avr_mcu->name, mcu_types[i].name);
return 1;
}
return 0;
*************** md_apply_fix3 (fixp, valuep, seg)
*** 818,831 ****
if (value < -2048 || value > 2047)
{
! if (avr_mcu->isa & AVR_ISA_WRAP)
! {
! if (value > 2047)
! value -= 4096;
! else
! value += 4096;
! }
! else
as_bad_where (fixp->fx_file, fixp->fx_line,
_("operand out of range: %ld"), value);
}
--- 828,835 ----
if (value < -2048 || value > 2047)
{
! /* No wrap for devices with >8K of program memory. */
! if (avr_mcu->isa & AVR_ISA_MEGA)
as_bad_where (fixp->fx_file, fixp->fx_line,
_("operand out of range: %ld"), value);
}
diff -Nrc3p orig/src/include/elf/avr.h src/include/elf/avr.h
*** orig/src/include/elf/avr.h Thu Jun 8 08:11:29 2000
--- src/include/elf/avr.h Mon Jun 26 11:55:05 2000
*************** along with this program; if not, write t
*** 30,35 ****
--- 30,36 ----
#define E_AVR_MACH_AVR2 2
#define E_AVR_MACH_AVR3 3
#define E_AVR_MACH_AVR4 4
+ #define E_AVR_MACH_AVR5 5
/* Relocations. */
START_RELOC_NUMBERS (elf_avr_reloc_type)
diff -Nrc3p orig/src/include/opcode/avr.h src/include/opcode/avr.h
*** orig/src/include/opcode/avr.h Mon Jun 12 07:44:50 2000
--- src/include/opcode/avr.h Mon Jun 26 12:13:02 2000
***************
*** 21,38 ****
#define AVR_ISA_LPM 0x0002 /* device has LPM */
#define AVR_ISA_LPMX 0x0004 /* device has LPM Rd,Z[+] */
#define AVR_ISA_SRAM 0x0008 /* device has SRAM (LD, ST, PUSH, POP, ...) */
! #define AVR_ISA_WRAP 0x0010 /* device has exactly 8K program memory */
! #define AVR_ISA_MEGA 0x0020 /* device has >8K program memory (JMP, CALL) */
#define AVR_ISA_MUL 0x0040 /* device has new core (MUL, MOVW, ...) */
#define AVR_ISA_ELPM 0x0080 /* device has >64K program memory (ELPM) */
#define AVR_ISA_ELPMX 0x0100 /* device has ELPM Rd,Z[+] (none yet) */
! #define AVR_ISA_SPM 0x0200 /* device can program itself (<=64K) */
! #define AVR_ISA_ESPM 0x0400 /* device can program itself (>64K, none yet) */
#define AVR_ISA_EIND 0x0800 /* device has >128K program memory (none yet) */
#define AVR_ISA_TINY1 (AVR_ISA_1200 | AVR_ISA_LPM)
#define AVR_ISA_2xxx (AVR_ISA_TINY1 | AVR_ISA_SRAM)
! #define AVR_ISA_85xx (AVR_ISA_2xxx | AVR_ISA_WRAP)
#define AVR_ISA_M603 (AVR_ISA_2xxx | AVR_ISA_MEGA)
#define AVR_ISA_M103 (AVR_ISA_M603 | AVR_ISA_ELPM)
#define AVR_ISA_M161 (AVR_ISA_M603 | AVR_ISA_MUL | AVR_ISA_LPMX | AVR_ISA_SPM)
--- 21,37 ----
#define AVR_ISA_LPM 0x0002 /* device has LPM */
#define AVR_ISA_LPMX 0x0004 /* device has LPM Rd,Z[+] */
#define AVR_ISA_SRAM 0x0008 /* device has SRAM (LD, ST, PUSH, POP, ...) */
! #define AVR_ISA_MEGA 0x0020 /* device has >8K program memory (JMP and CALL
! supported, no 8K wrap on RJMP and RCALL) */
#define AVR_ISA_MUL 0x0040 /* device has new core (MUL, MOVW, ...) */
#define AVR_ISA_ELPM 0x0080 /* device has >64K program memory (ELPM) */
#define AVR_ISA_ELPMX 0x0100 /* device has ELPM Rd,Z[+] (none yet) */
! #define AVR_ISA_SPM 0x0200 /* device can program itself */
#define AVR_ISA_EIND 0x0800 /* device has >128K program memory (none yet) */
#define AVR_ISA_TINY1 (AVR_ISA_1200 | AVR_ISA_LPM)
#define AVR_ISA_2xxx (AVR_ISA_TINY1 | AVR_ISA_SRAM)
! #define AVR_ISA_M83 (AVR_ISA_2xxx | AVR_ISA_MUL | AVR_ISA_LPMX | AVR_ISA_SPM)
#define AVR_ISA_M603 (AVR_ISA_2xxx | AVR_ISA_MEGA)
#define AVR_ISA_M103 (AVR_ISA_M603 | AVR_ISA_ELPM)
#define AVR_ISA_M161 (AVR_ISA_M603 | AVR_ISA_MUL | AVR_ISA_LPMX | AVR_ISA_SPM)
*************** AVR_INSN (mulsu,"a,a", "000000110ddd0rrr
*** 191,202 ****
AVR_INSN (fmul, "a,a", "000000110ddd1rrr", 1, AVR_ISA_MUL, 0x0308)
AVR_INSN (fmuls,"a,a", "000000111ddd0rrr", 1, AVR_ISA_MUL, 0x0380)
AVR_INSN (fmulsu,"a,a","000000111ddd1rrr", 1, AVR_ISA_MUL, 0x0388)
! /* these are for devices that don't exists yet */
! /* >64K program memory, new core */
! AVR_INSN (espm, "", "1001010111111000", 1, AVR_ISA_ESPM, 0x95f8)
! /* >128K program memory (PC = EIND:Z) */
! AVR_INSN (eicall, "", "1001010100011001", 1, AVR_ISA_EIND, 0x9519)
! AVR_INSN (eijmp, "", "1001010000011001", 1, AVR_ISA_EIND, 0x9419)
AVR_INSN (sts, "i,r", "1001001ddddd0000", 2, AVR_ISA_2xxx, 0x9200)
AVR_INSN (lds, "r,i", "1001000ddddd0000", 2, AVR_ISA_2xxx, 0x9000)
AVR_INSN (ldd, "r,b", "10o0oo0dddddbooo", 1, AVR_ISA_2xxx, 0x8000)
--- 190,196 ----
AVR_INSN (fmul, "a,a", "000000110ddd1rrr", 1, AVR_ISA_MUL, 0x0308)
AVR_INSN (fmuls,"a,a", "000000111ddd0rrr", 1, AVR_ISA_MUL, 0x0380)
AVR_INSN (fmulsu,"a,a","000000111ddd1rrr", 1, AVR_ISA_MUL, 0x0388)
!
AVR_INSN (sts, "i,r", "1001001ddddd0000", 2, AVR_ISA_2xxx, 0x9200)
AVR_INSN (lds, "r,i", "1001000ddddd0000", 2, AVR_ISA_2xxx, 0x9000)
AVR_INSN (ldd, "r,b", "10o0oo0dddddbooo", 1, AVR_ISA_2xxx, 0x8000)
*************** AVR_INSN (std, "b,r", "10o0oo1rrrrrbooo
*** 204,207 ****
--- 198,207 ----
/* ee = {X=11,Y=10,Z=00, 0) */
AVR_INSN (ld, "r,e", "100!000dddddee-+", 1, AVR_ISA_1200, 0x8000)
AVR_INSN (st, "e,r", "100!001rrrrree-+", 1, AVR_ISA_1200, 0x8200)
+
+ /* these are for devices that don't exist yet */
+ /* espm (0x95f8) removed in databook update, use spm with RAMPZ:Z */
+ /* >128K program memory (PC = EIND:Z) */
+ AVR_INSN (eicall, "", "1001010100011001", 1, AVR_ISA_EIND, 0x9519)
+ AVR_INSN (eijmp, "", "1001010000011001", 1, AVR_ISA_EIND, 0x9419)
diff -Nrc3p orig/src/ld/emulparams/avrmega161.sh src/ld/emulparams/avrmega161.sh
*** orig/src/ld/emulparams/avrmega161.sh Mon May 29 07:54:24 2000
--- src/ld/emulparams/avrmega161.sh Mon Jun 26 12:25:42 2000
***************
*** 1,4 ****
! ARCH=avr:4
MACHINE=
SCRIPT_NAME=elf32avr
OUTPUT_FORMAT="elf32-avr"
--- 1,4 ----
! ARCH=avr:5
MACHINE=
SCRIPT_NAME=elf32avr
OUTPUT_FORMAT="elf32-avr"