openbsd-ports/devel/avr/binutils/patches/patch-bfd_coffcode_h
ckuethe ebcb40e5e1 Update to the latest AVR gcc, binutils, libc and gdb. Based on the FreeBSD
port, which is also in sync with winavr/avrstudio. Among other things, this
adds support for atmega328... which means new arduino boards should work.
2010-06-27 20:58:10 +00:00

139 lines
4.3 KiB
Plaintext

$OpenBSD: patch-bfd_coffcode_h,v 1.3 2010/06/27 20:58:10 ckuethe Exp $
--- bfd/coffcode.h.orig Sat Jun 26 11:23:52 2010
+++ bfd/coffcode.h Sat Jun 26 11:31:17 2010
@@ -1,3 +1,4 @@
+
/* Support for the generic parts of most COFF variants, for BFD.
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
@@ -1910,6 +1911,17 @@ coff_mkobject (bfd * abfd)
coff->relocbase = 0;
coff->local_toc_sym_map = 0;
+ /* These members communicate important constants about the symbol
+ table to GDB's symbol-reading code. These `constants'
+ unfortunately vary among coff implementations... */
+ coff->local_n_btmask = N_BTMASK;
+ coff->local_n_btshft = N_BTSHFT;
+ coff->local_n_tmask = N_TMASK;
+ coff->local_n_tshift = N_TSHIFT;
+ coff->local_symesz = bfd_coff_symesz (abfd);
+ coff->local_auxesz = bfd_coff_auxesz (abfd);
+ coff->local_linesz = bfd_coff_linesz (abfd);
+
/* make_abs_section(abfd);*/
return TRUE;
@@ -1934,17 +1946,6 @@ coff_mkobject_hook (bfd * abfd,
coff->sym_filepos = internal_f->f_symptr;
- /* These members communicate important constants about the symbol
- table to GDB's symbol-reading code. These `constants'
- unfortunately vary among coff implementations... */
- coff->local_n_btmask = N_BTMASK;
- coff->local_n_btshft = N_BTSHFT;
- coff->local_n_tmask = N_TMASK;
- coff->local_n_tshift = N_TSHIFT;
- coff->local_symesz = bfd_coff_symesz (abfd);
- coff->local_auxesz = bfd_coff_auxesz (abfd);
- coff->local_linesz = bfd_coff_linesz (abfd);
-
coff->timestamp = internal_f->f_timdat;
obj_raw_syment_count (abfd) =
@@ -2076,6 +2077,11 @@ coff_set_arch_mach_hook (bfd *abfd, void * filehdr)
}
break;
#endif
+#ifdef AVRMAGIC
+ case AVRMAGIC:
+ arch = bfd_arch_avr;
+ break;
+#endif
#ifdef MC68MAGIC
case MC68MAGIC:
case M68MAGIC:
@@ -2871,6 +2877,13 @@ coff_set_flags (bfd * abfd,
return TRUE;
#endif
+#ifdef AVRMAGIC
+ case bfd_arch_avr:
+ *magicp = AVRMAGIC;
+ return TRUE;
+ break;
+#endif
+
#ifdef PPCMAGIC
case bfd_arch_powerpc:
*magicp = PPCMAGIC;
@@ -3698,6 +3711,11 @@ coff_write_object_contents (bfd * abfd)
section.s_page = 0;
#endif
+#ifdef AVR
+ /* AVR uses s_paddr the way GNU uses s_vaddr, and effectively
+ ignores s_vaddr. */
+ section.s_paddr = current->vma;
+#endif
#ifdef COFF_WITH_PE
section.s_paddr = 0;
#endif
@@ -4042,6 +4060,17 @@ coff_write_object_contents (bfd * abfd)
internal_a.magic = ZMAGIC;
#endif
+#ifdef AVR
+ /* a.out is a dummy for non-extended COFF */
+ internal_a.magic = AVRAOUTMAGIC;
+ /* Upper nibble of f_flags must be set for historical reasons.
+ The upper byte remains blank on coff-avr, so undo the F_AR32WR
+ setting performed above. */
+ internal_f.f_flags |= F_JUNK;
+ internal_f.f_flags &= ~F_UNUSED;
+#define __A_MAGIC_SET__
+#endif /* AVR */
+
#if defined(PPC_PE)
#define __A_MAGIC_SET__
internal_a.magic = IMAGE_NT_OPTIONAL_HDR_MAGIC;
@@ -4109,8 +4138,16 @@ coff_write_object_contents (bfd * abfd)
#endif
}
+#ifdef AVR_EXT_COFF
+ /* Note that we do not set F_PTRINFO because the GNU toolchain
+ doesn't provide any information about the target of a pointer,
+ so we cannot derive which section our pointer target would be
+ in. */
+ internal_a.vstamp = F_FULLPATHS | F_STRUCTINFO;
+#else
/* FIXME: Does anybody ever set this to another value? */
internal_a.vstamp = 0;
+#endif
/* Now should write relocs, strings, syms. */
obj_sym_filepos (abfd) = sym_base;
@@ -4668,6 +4705,10 @@ coff_slurp_symbol_table (bfd * abfd)
/* In PE, 0x69 (105) denotes a weak external symbol. */
case C_NT_WEAK:
#endif
+#ifdef AVR
+ /* Some AVR COFF compilers handle EXTDEF like EXT. */
+ case C_EXTDEF: /* external definition */
+#endif
switch (coff_classify_symbol (abfd, &src->u.syment))
{
case COFF_SYMBOL_GLOBAL:
@@ -4891,7 +4932,9 @@ coff_slurp_symbol_table (bfd * abfd)
&& src->u.syment.n_scnum == 0)
break;
/* Fall through. */
+#if !defined(AVR)
case C_EXTDEF: /* External definition. */
+#endif
case C_ULABEL: /* Undefined label. */
case C_USTATIC: /* Undefined static. */
#ifndef COFF_WITH_PE