Index: bfd/elf.c =================================================================== RCS file: /cvsroot/gnusrc/gnu/dist/toolchain/bfd/elf.c,v retrieving revision 1.9 diff -u -r1.9 elf.c --- bfd/elf.c 2002/05/06 17:59:18 1.9 +++ bfd/elf.c 2002/11/30 17:39:29 @@ -584,6 +584,7 @@ case PT_NOTE: s = "NOTE"; break; case PT_SHLIB: s = "SHLIB"; break; case PT_PHDR: s = "PHDR"; break; + case PT_NB_CKSUM: s = "NB_CKSUM"; break; default: sprintf (buf, "0x%lx", p->p_type); s = buf; break; } fprintf (f, "%8s off 0x", s); @@ -1736,6 +1737,11 @@ /* FIXME: This should not be based on section names. */ if (strcmp (asect->name, ".dynstr") == 0) this_hdr->sh_type = SHT_STRTAB; + else if (strcmp (asect->name, ".cksum") == 0) + { + this_hdr->sh_type = SHT_NOTE; + this_hdr->sh_entsize = 0; + } else if (strcmp (asect->name, ".hash") == 0) { this_hdr->sh_type = SHT_HASH; @@ -2436,6 +2442,22 @@ pm = &m->next; } + s = bfd_get_section_by_name (abfd, ".cksum"); + if (s != NULL && (s->flags & SEC_LOAD) != 0) + { + m = ((struct elf_segment_map *) + bfd_zalloc (abfd, sizeof (struct elf_segment_map))); + if (m == NULL) + goto error_return; + m->next = NULL; + m->p_type = PT_NB_CKSUM; + m->count = 1; + m->sections[0] = s; + + *pm = m; + pm = &m->next; + } + /* Look through the sections. We put sections in the same program segment when the start of the second section can be placed within a few bytes of the end of the first section. */ @@ -3111,6 +3133,12 @@ PT_PHDR segment, although that may not be true for all targets. */ segs += 2; + } + + if (bfd_get_section_by_name (abfd, ".cksum") != NULL) + { + /* We need a PT_NB_CKSUM segment. */ + ++segs; } if (bfd_get_section_by_name (abfd, ".dynamic") != NULL) Index: bfd/elflink.h =================================================================== RCS file: /cvsroot/gnusrc/gnu/dist/toolchain/bfd/elflink.h,v retrieving revision 1.5 diff -u -r1.5 elflink.h --- bfd/elflink.h 2001/08/14 04:43:07 1.5 +++ bfd/elflink.h 2002/11/30 17:39:31 @@ -2288,6 +2288,12 @@ && ! _bfd_elf_link_record_dynamic_symbol (info, h)) return false; + s = bfd_make_section (abfd, ".cksum"); + if (s == NULL + || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY) + || ! bfd_set_section_alignment (abfd, s, LOG_FILE_ALIGN)) + return false; + bed = get_elf_backend_data (abfd); s = bfd_make_section (abfd, ".hash"); @@ -3376,7 +3382,7 @@ return false; } - /* Set the size of the .dynsym and .hash sections. We counted + /* Set the size of the .dynsym, .cksum and .hash sections. We counted the number of dynamic symbols in elf_link_add_object_symbols. We will build the contents of .dynsym and .hash when we build the final symbol table, because until then we do not know the @@ -3406,6 +3412,14 @@ (PTR) (Elf_External_Sym *) s->contents); } + s = bfd_get_section_by_name (dynobj, ".cksum"); + BFD_ASSERT (s != NULL); + s->_raw_size = 33; + s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size); + if (s->contents == NULL) + return false; + memset (s->contents, 0, (size_t) s->_raw_size); + /* Compute the size of the hashing table. As a side effect this computes the hash values for all the names we export. */ bucketcount = compute_bucket_count (info); Index: binutils/readelf.c =================================================================== RCS file: /cvsroot/gnusrc/gnu/dist/toolchain/binutils/readelf.c,v retrieving revision 1.4 diff -u -r1.4 readelf.c --- binutils/readelf.c 2002/01/28 21:39:07 1.4 +++ binutils/readelf.c 2002/11/30 17:39:36 @@ -1709,6 +1709,8 @@ case PT_SHLIB: return "SHLIB"; case PT_PHDR: return "PHDR"; + case PT_NB_CKSUM: return "NB_CKSUM"; + default: if ((p_type >= PT_LOPROC) && (p_type <= PT_HIPROC)) { Index: include/elf/common.h =================================================================== RCS file: /cvsroot/gnusrc/gnu/dist/toolchain/include/elf/common.h,v retrieving revision 1.1.1.4 diff -u -r1.1.1.4 common.h --- include/elf/common.h 2001/08/14 02:56:34 1.1.1.4 +++ include/elf/common.h 2002/11/30 17:39:39 @@ -237,6 +237,8 @@ #define PT_LOPROC 0x70000000 /* Processor-specific */ #define PT_HIPROC 0x7FFFFFFF /* Processor-specific */ +#define PT_NB_CKSUM (PT_LOOS + 0x8ffffff) /* NetBSD-specific checksum */ + /* Program segment permissions, in program header p_flags field. */ #define PF_X (1 << 0) /* Segment is executable */ Index: ld/scripttempl/elf.sc =================================================================== RCS file: /cvsroot/gnusrc/gnu/dist/toolchain/ld/scripttempl/elf.sc,v retrieving revision 1.1.1.3 diff -u -r1.1.1.3 elf.sc --- ld/scripttempl/elf.sc 2001/04/23 12:29:24 1.1.1.3 +++ ld/scripttempl/elf.sc 2002/11/30 17:39:43 @@ -137,6 +137,7 @@ ${CREATE_SHLIB-${INTERP}} ${INITIAL_READONLY_SECTIONS} ${TEXT_DYNAMIC+${DYNAMIC}} + .cksum ${RELOCATING-0} : { *(.cksum) } .hash ${RELOCATING-0} : { *(.hash) } .dynsym ${RELOCATING-0} : { *(.dynsym) } .dynstr ${RELOCATING-0} : { *(.dynstr) }