diff options
author | Timothy Wall <twall@alum.mit.edu> | 2000-04-18 02:21:27 +0000 |
---|---|---|
committer | Timothy Wall <twall@alum.mit.edu> | 2000-04-18 02:21:27 +0000 |
commit | b9af77f58f609c230732b9acdbf1a6f747766733 (patch) | |
tree | 0cb26da3871aa90de804d13bc8089d3970d61b79 | |
parent | 63fa1674919c94757f30a6e050f015eba30ee229 (diff) | |
download | gdb-b9af77f58f609c230732b9acdbf1a6f747766733.zip gdb-b9af77f58f609c230732b9acdbf1a6f747766733.tar.gz gdb-b9af77f58f609c230732b9acdbf1a6f747766733.tar.bz2 |
Clean up load page support for tic54x.
-rw-r--r-- | bfd/ChangeLog | 10 | ||||
-rw-r--r-- | bfd/bfd-in.h | 7 | ||||
-rw-r--r-- | bfd/bfd-in2.h | 7 | ||||
-rw-r--r-- | bfd/coff-tic54x.c | 86 | ||||
-rw-r--r-- | bfd/coffcode.h | 7 | ||||
-rw-r--r-- | include/coff/ChangeLog | 5 | ||||
-rw-r--r-- | include/coff/internal.h | 1 | ||||
-rw-r--r-- | include/coff/ti.h | 29 |
8 files changed, 122 insertions, 30 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 72d2896..a58eefb 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,13 @@ +2000-04-17 Timothy Wall <twall@cygnus.com> + + * bfd-in2.h: Add prototypes for tic54x load page access. + * bfd-in.h: Regenerate. + * coff-tic54x.c: Add load page functions; allow bfd_arch_unknown + in customized _set_arch_mach function. + * coffcode.h (coff_set_alignment_hook): Set section load page if + the appropriate macro is defined. + (write_object_contents): Read section load page. + 2000-04-13 Alan Modra <alan@linuxcare.com.au> * elf32-hppa.h: Update copyright date. diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h index 1f67c0c..91b7868 100644 --- a/bfd/bfd-in.h +++ b/bfd/bfd-in.h @@ -748,4 +748,11 @@ extern boolean bfd_elf32_arm_process_before_allocation extern boolean bfd_elf32_arm_get_bfd_for_interworking PARAMS ((bfd *, struct bfd_link_info *)); +/* TI COFF load page support. */ +extern void bfd_ticoff_set_section_load_page + PARAMS ((struct sec *, int)); + +extern int bfd_ticoff_get_section_load_page + PARAMS ((struct sec *)); + /* And more from the source. */ diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 79080cb..a3f15c9 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -748,6 +748,13 @@ extern boolean bfd_elf32_arm_process_before_allocation extern boolean bfd_elf32_arm_get_bfd_for_interworking PARAMS ((bfd *, struct bfd_link_info *)); +/* TI COFF load page support. */ +extern void bfd_ticoff_set_section_load_page + PARAMS ((struct sec *, int)); + +extern int bfd_ticoff_get_section_load_page + PARAMS ((struct sec *)); + /* And more from the source. */ void bfd_init PARAMS ((void)); diff --git a/bfd/coff-tic54x.c b/bfd/coff-tic54x.c index d27522a..4cfa27e 100644 --- a/bfd/coff-tic54x.c +++ b/bfd/coff-tic54x.c @@ -76,6 +76,56 @@ tic54x_getl_signed_32 (addr) return COERCE32 (v); } +#define coff_get_section_load_page bfd_ticoff_get_section_load_page +#define coff_set_section_load_page bfd_ticoff_set_section_load_page + +void +bfd_ticoff_set_section_load_page (sect, page) + asection *sect; + int page; +{ + sect->lma = (sect->lma & ADDR_MASK) | PG_TO_FLAG(page); +} + + +int +bfd_ticoff_get_section_load_page (sect) + asection *sect; +{ + int page; + + /* Provide meaningful defaults for predefined sections. */ + if (sect == &bfd_com_section) + page = PG_DATA; + + else if (sect == &bfd_und_section + || sect == &bfd_abs_section + || sect == &bfd_ind_section) + page = PG_PROG; + + else + page = FLAG_TO_PG (sect->lma); + + return page; +} + +/* Set the architecture appropriately. Allow unkown architectures + (e.g. binary). */ +static boolean +tic54x_set_arch_mach (abfd, arch, machine) + bfd *abfd; + enum bfd_architecture arch; + unsigned long machine; +{ + if (arch == bfd_arch_unknown) + arch = bfd_arch_tic54x; + + else if (arch != bfd_arch_tic54x) + return false; + + return bfd_default_set_arch_mach (abfd, arch, machine); +} + static bfd_reloc_status_type tic54x_relocation (abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message) @@ -295,6 +345,18 @@ ticoff_bfd_is_local_label_name (abfd, name) #define BADMAG(x) COFF2_BADMAG(x) #include "coffcode.h" +static boolean +tic54x_set_section_contents (abfd, section, location, offset, bytes_to_do) + bfd *abfd; + sec_ptr section; + PTR location; + file_ptr offset; + bfd_size_type bytes_to_do; +{ + return coff_set_section_contents (abfd, section, location, + offset, bytes_to_do); +} + static void tic54x_reloc_processing (relent, reloc, symbols, abfd, section) arelent *relent; @@ -420,7 +482,7 @@ const bfd_target tic54x_coff0_vec = (HAS_RELOC | EXEC_P | /* object flags */ HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | WP_TEXT /*| HAS_LOAD_PAGE*/ ), + HAS_SYMS | HAS_LOCALS | WP_TEXT ), (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ '_', /* leading symbol underscore */ @@ -446,7 +508,7 @@ const bfd_target tic54x_coff0_vec = BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff), BFD_JUMP_TABLE_SYMBOLS (coff), BFD_JUMP_TABLE_RELOCS (coff), - BFD_JUMP_TABLE_WRITE (coff), + BFD_JUMP_TABLE_WRITE (tic54x), BFD_JUMP_TABLE_LINK (coff), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), NULL, @@ -464,7 +526,7 @@ const bfd_target tic54x_coff0_beh_vec = (HAS_RELOC | EXEC_P | /* object flags */ HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | WP_TEXT /*| HAS_LOAD_PAGE*/ ), + HAS_SYMS | HAS_LOCALS | WP_TEXT ), (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ '_', /* leading symbol underscore */ @@ -490,7 +552,7 @@ const bfd_target tic54x_coff0_beh_vec = BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff), BFD_JUMP_TABLE_SYMBOLS (coff), BFD_JUMP_TABLE_RELOCS (coff), - BFD_JUMP_TABLE_WRITE (coff), + BFD_JUMP_TABLE_WRITE (tic54x), BFD_JUMP_TABLE_LINK (coff), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), @@ -509,7 +571,7 @@ const bfd_target tic54x_coff1_vec = (HAS_RELOC | EXEC_P | /* object flags */ HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | WP_TEXT /*| HAS_LOAD_PAGE*/ ), + HAS_SYMS | HAS_LOCALS | WP_TEXT ), (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ '_', /* leading symbol underscore */ @@ -535,7 +597,7 @@ const bfd_target tic54x_coff1_vec = BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff), BFD_JUMP_TABLE_SYMBOLS (coff), BFD_JUMP_TABLE_RELOCS (coff), - BFD_JUMP_TABLE_WRITE (coff), + BFD_JUMP_TABLE_WRITE (tic54x), BFD_JUMP_TABLE_LINK (coff), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), @@ -554,7 +616,7 @@ const bfd_target tic54x_coff1_beh_vec = (HAS_RELOC | EXEC_P | /* object flags */ HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | WP_TEXT /*| HAS_LOAD_PAGE*/ ), + HAS_SYMS | HAS_LOCALS | WP_TEXT ), (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ '_', /* leading symbol underscore */ @@ -580,7 +642,7 @@ const bfd_target tic54x_coff1_beh_vec = BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff), BFD_JUMP_TABLE_SYMBOLS (coff), BFD_JUMP_TABLE_RELOCS (coff), - BFD_JUMP_TABLE_WRITE (coff), + BFD_JUMP_TABLE_WRITE (tic54x), BFD_JUMP_TABLE_LINK (coff), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), @@ -599,7 +661,7 @@ const bfd_target tic54x_coff2_vec = (HAS_RELOC | EXEC_P | /* object flags */ HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | WP_TEXT /*| HAS_LOAD_PAGE*/ ), + HAS_SYMS | HAS_LOCALS | WP_TEXT ), (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ '_', /* leading symbol underscore */ @@ -625,7 +687,7 @@ const bfd_target tic54x_coff2_vec = BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff), BFD_JUMP_TABLE_SYMBOLS (coff), BFD_JUMP_TABLE_RELOCS (coff), - BFD_JUMP_TABLE_WRITE (coff), + BFD_JUMP_TABLE_WRITE (tic54x), BFD_JUMP_TABLE_LINK (coff), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), @@ -644,7 +706,7 @@ const bfd_target tic54x_coff2_beh_vec = (HAS_RELOC | EXEC_P | /* object flags */ HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | WP_TEXT /*| HAS_LOAD_PAGE*/ ), + HAS_SYMS | HAS_LOCALS | WP_TEXT ), (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ '_', /* leading symbol underscore */ @@ -670,7 +732,7 @@ const bfd_target tic54x_coff2_beh_vec = BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff), BFD_JUMP_TABLE_SYMBOLS (coff), BFD_JUMP_TABLE_RELOCS (coff), - BFD_JUMP_TABLE_WRITE (coff), + BFD_JUMP_TABLE_WRITE (tic54x), BFD_JUMP_TABLE_LINK (coff), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), diff --git a/bfd/coffcode.h b/bfd/coffcode.h index 40ba6ae..a6e8b08 100644 --- a/bfd/coffcode.h +++ b/bfd/coffcode.h @@ -1531,6 +1531,10 @@ coff_set_alignment_hook (abfd, section, scnhdr) i = COFF_DECODE_ALIGNMENT(hdr->s_flags); #endif section->alignment_power = i; + +#ifdef coff_set_section_load_page + coff_set_section_load_page (section, hdr->s_page); +#endif } #else /* ! COFF_ALIGN_IN_SECTION_HEADER */ @@ -3249,6 +3253,9 @@ coff_write_object_contents (abfd) section.s_vaddr = current->vma; section.s_paddr = current->lma; section.s_size = current->_raw_size; +#ifdef coff_get_section_load_page + section.s_page = coff_get_section_load_page (current); +#endif #ifdef COFF_WITH_PE section.s_paddr = 0; diff --git a/include/coff/ChangeLog b/include/coff/ChangeLog index 401fbee..dd6ca19 100644 --- a/include/coff/ChangeLog +++ b/include/coff/ChangeLog @@ -1,3 +1,8 @@ +2000-04-17 Timothy Wall <twall@cygnus.com> + + * ti.h: Load page cleanup. + * intental.h: Add load page field. + Mon Apr 17 16:44:01 2000 David Mosberger <davidm@hpl.hp.com> * pe.h (PEP64AOUTHDR): New header for PE+. diff --git a/include/coff/internal.h b/include/coff/internal.h index a9f64c0..c6f2760 100644 --- a/include/coff/internal.h +++ b/include/coff/internal.h @@ -303,6 +303,7 @@ struct internal_scnhdr unsigned long s_nlnno; /* number of line number entries*/ long s_flags; /* flags */ long s_align; /* used on I960 */ + unsigned char s_page; /* TI COFF load page */ }; /* diff --git a/include/coff/ti.h b/include/coff/ti.h index 306ad7b..fb3456d 100644 --- a/include/coff/ti.h +++ b/include/coff/ti.h @@ -71,12 +71,10 @@ struct external_filehdr { #define COFF2_BADMAG(x) ((x).f_magic != TICOFF2MAGIC || (x).f_target_id != TI_TARGET_ID) /* we need to read/write an extra field in the coff file header */ -/* FIXME load page */ #ifndef COFF_ADJUST_FILEHDR_IN_POST #define COFF_ADJUST_FILEHDR_IN_POST(abfd,src,dst) \ do { ((struct internal_filehdr *)(dst))->f_target_id = \ bfd_h_get_16(abfd, (bfd_byte *)(((FILHDR *)(src))->f_target_id)); \ -/*((struct internal_filehdr *)(dst))->f_flags |= F_LDPAGE;*/ \ } while(0) #endif @@ -161,9 +159,6 @@ struct external_scnhdr { /* * Special section flags */ -/* recognized load pages */ -#define PG_PROG 0x0 /* PROG page */ -#define PG_DATA 0x1 /* DATA page */ /* TI COFF defines these flags; STYP_CLINK: the section should be excluded from the final @@ -212,18 +207,15 @@ bfd_h_put_8 (ABFD,VAL,(PTR)-7), bfd_h_put_8 (ABFD, 0, (PTR)-8)) #define PUT_SCNHDR_SIZE(ABFD,SZ,SZP) \ bfd_h_put_32(ABFD,(SZ)/bfd_octets_per_byte(ABFD),SZP) -/* FIXME load page #define COFF_ADJUST_SCNHDR_IN_POST(ABFD,EXT,INT) \ do { ((struct internal_scnhdr *)(INT))->s_page = \ GET_SCNHDR_PAGE(ABFD,(bfd_byte *)((SCNHDR *)(EXT))->s_page); \ } while(0) -*/ /* The line number and reloc overflow checking in coff_swap_scnhdr_out in coffswap.h doesn't use PUT_X for s_nlnno and s_nreloc. Due to different sized v0/v1/v2 section headers, we have to re-write these fields. - FIXME load page */ #define COFF_ADJUST_SCNHDR_OUT_POST(ABFD,INT,EXT) \ do { \ @@ -233,13 +225,13 @@ PUT_SCNHDR_NRELOC(ABFD,((struct internal_scnhdr *)(INT))->s_nreloc,\ (bfd_byte *)((SCNHDR *)(EXT))->s_nreloc); \ PUT_SCNHDR_FLAGS(ABFD,((struct internal_scnhdr *)(INT))->s_flags, \ (bfd_byte *)((SCNHDR *)(EXT))->s_flags); \ -/*PUT_SCNHDR_PAGE(ABFD,((struct internal_scnhdr *)(INT))->s_page, \ - (bfd_byte *)((SCNHDR *)(EXT))->s_page);*/ \ +PUT_SCNHDR_PAGE(ABFD,((struct internal_scnhdr *)(INT))->s_page, \ + (bfd_byte *)((SCNHDR *)(EXT))->s_page); \ } while(0) -/* page macros +/* Page macros - the first GDB port requires flags in its remote memory access commands to + The first GDB port requires flags in its remote memory access commands to distinguish between data/prog space. hopefully we can make this go away eventually. stuff the page in the upper bits of a 32-bit address, since the c5x family only uses 16 or 23 bits. @@ -250,12 +242,13 @@ PUT_SCNHDR_FLAGS(ABFD,((struct internal_scnhdr *)(INT))->s_flags, \ addresses. */ -#define LONG_ADDRESSES 1 -#define PG_SHIFT (LONG_ADDRESSES ? 30 : 16) -#define ADDR_MASK (((unsigned long) 1 << PG_SHIFT) - 1) -#define PG_MASK ((unsigned long) 3 << PG_SHIFT) -#define PG_TO_FLAG(p) ((p) << PG_SHIFT) -#define FLAG_TO_PG(f) (((f) & PG_MASK) >> PG_SHIFT) +/* recognized load pages */ +#define PG_PROG 0x0 /* PROG page */ +#define PG_DATA 0x1 /* DATA page */ + +#define ADDR_MASK 0x00FFFFFF +#define PG_TO_FLAG(p) (((unsigned long)(p) & 0xFF) << 24) +#define FLAG_TO_PG(f) (((f) >> 24) & 0xFF) /* * names of "special" sections |