* pe-dll.c (autofilter_entry_type): Change name to const.

(pe_details_type) : Change target_name, object_target and autofilter_symbollist
to const.
(autofilter_symbollist_generic): Change to const.
(autofilter_symbollist_i386, pe_detail_list, pe_details, autofilter_liblist,
autofilter_objlist autofilter_symbolprefixlist, autofilter_symbolsuffixlist):
Likewise.
(is_import): Fix indentation.
(auto_export): Change afptr to const.  Move name declaration to beginning of
scope.
(make_tail): Clear undefined byte.
(jmp_ix86_bytes, jmp_sh_bytes, jmp_mips_bytes, jmp_arm_bytes): Change to const.
(make_one): Change jmp_bytes to const.  Make idata$6 member size arithmetic
explicit and add comment.
This commit is contained in:
Christopher Faylor 2006-11-01 00:48:25 +00:00
parent fe2dce6741
commit e916811ac6
2 changed files with 45 additions and 21 deletions

View file

@ -1,3 +1,21 @@
2006-10-31 Pedro Alves <pedro_alves@portugalmail.pt>
* pe-dll.c (autofilter_entry_type): Change name to const.
(pe_details_type) : Change target_name, object_target and
autofilter_symbollist to const.
(autofilter_symbollist_generic): Change to const.
(autofilter_symbollist_i386, pe_detail_list, pe_details,
autofilter_liblist, autofilter_objlist autofilter_symbolprefixlist,
autofilter_symbolsuffixlist): Likewise.
(is_import): Fix indentation.
(auto_export): Change afptr to const. Move name declaration to
beginning of scope.
(make_tail): Clear undefined byte.
(jmp_ix86_bytes, jmp_sh_bytes, jmp_mips_bytes, jmp_arm_bytes): Change
to const.
(make_one): Change jmp_bytes to const. Make idata$6 member size
arithmetic explicit and add comment.
2006-10-30 H.J. Lu <hongjiu.lu@intel.com> 2006-10-30 H.J. Lu <hongjiu.lu@intel.com>
PR ld/3111 PR ld/3111

View file

@ -167,24 +167,24 @@ static int runtime_pseudo_relocs_created = 0;
typedef struct typedef struct
{ {
char *name; const char *name;
int len; int len;
} }
autofilter_entry_type; autofilter_entry_type;
typedef struct typedef struct
{ {
char *target_name; const char *target_name;
char *object_target; const char *object_target;
unsigned int imagebase_reloc; unsigned int imagebase_reloc;
int pe_arch; int pe_arch;
int bfd_arch; int bfd_arch;
bfd_boolean underscored; bfd_boolean underscored;
autofilter_entry_type* autofilter_symbollist; const autofilter_entry_type* autofilter_symbollist;
} }
pe_details_type; pe_details_type;
static autofilter_entry_type autofilter_symbollist_generic[] = static const autofilter_entry_type autofilter_symbollist_generic[] =
{ {
{ STRING_COMMA_LEN (".text") }, { STRING_COMMA_LEN (".text") },
/* Entry point symbols. */ /* Entry point symbols. */
@ -197,7 +197,7 @@ static autofilter_entry_type autofilter_symbollist_generic[] =
{ STRING_COMMA_LEN (NULL) } { STRING_COMMA_LEN (NULL) }
}; };
static autofilter_entry_type autofilter_symbollist_i386[] = static const autofilter_entry_type autofilter_symbollist_i386[] =
{ {
{ STRING_COMMA_LEN (".text") }, { STRING_COMMA_LEN (".text") },
/* Entry point symbols, and entry hooks. */ /* Entry point symbols, and entry hooks. */
@ -231,7 +231,7 @@ static autofilter_entry_type autofilter_symbollist_i386[] =
#define PE_ARCH_arm_epoc 5 #define PE_ARCH_arm_epoc 5
#define PE_ARCH_arm_wince 6 #define PE_ARCH_arm_wince 6
static pe_details_type pe_detail_list[] = static const pe_details_type pe_detail_list[] =
{ {
{ {
#ifdef pe_use_x86_64 #ifdef pe_use_x86_64
@ -296,10 +296,10 @@ static pe_details_type pe_detail_list[] =
{ NULL, NULL, 0, 0, 0, FALSE, NULL } { NULL, NULL, 0, 0, 0, FALSE, NULL }
}; };
static pe_details_type *pe_details; static const pe_details_type *pe_details;
/* Do not specify library suffix explicitly, to allow for dllized versions. */ /* Do not specify library suffix explicitly, to allow for dllized versions. */
static autofilter_entry_type autofilter_liblist[] = static const autofilter_entry_type autofilter_liblist[] =
{ {
{ STRING_COMMA_LEN ("libcegcc") }, { STRING_COMMA_LEN ("libcegcc") },
{ STRING_COMMA_LEN ("libcygwin") }, { STRING_COMMA_LEN ("libcygwin") },
@ -314,7 +314,7 @@ static autofilter_entry_type autofilter_liblist[] =
{ STRING_COMMA_LEN (NULL) } { STRING_COMMA_LEN (NULL) }
}; };
static autofilter_entry_type autofilter_objlist[] = static const autofilter_entry_type autofilter_objlist[] =
{ {
{ STRING_COMMA_LEN ("crt0.o") }, { STRING_COMMA_LEN ("crt0.o") },
{ STRING_COMMA_LEN ("crt1.o") }, { STRING_COMMA_LEN ("crt1.o") },
@ -329,7 +329,7 @@ static autofilter_entry_type autofilter_objlist[] =
{ STRING_COMMA_LEN (NULL) } { STRING_COMMA_LEN (NULL) }
}; };
static autofilter_entry_type autofilter_symbolprefixlist[] = static const autofilter_entry_type autofilter_symbolprefixlist[] =
{ {
/* _imp_ is treated specially, as it is always underscored. */ /* _imp_ is treated specially, as it is always underscored. */
/* { STRING_COMMA_LEN ("_imp_") }, */ /* { STRING_COMMA_LEN ("_imp_") }, */
@ -343,7 +343,7 @@ static autofilter_entry_type autofilter_symbolprefixlist[] =
{ STRING_COMMA_LEN (NULL) } { STRING_COMMA_LEN (NULL) }
}; };
static autofilter_entry_type autofilter_symbolsuffixlist[] = static const autofilter_entry_type autofilter_symbolsuffixlist[] =
{ {
{ STRING_COMMA_LEN ("_iname") }, { STRING_COMMA_LEN ("_iname") },
{ STRING_COMMA_LEN (NULL) } { STRING_COMMA_LEN (NULL) }
@ -449,7 +449,7 @@ pe_dll_add_excludes (const char *new_excludes, const int type)
static bfd_boolean static bfd_boolean
is_import (const char* n) is_import (const char* n)
{ {
return (CONST_STRNEQ (n, "__imp_")); return (CONST_STRNEQ (n, "__imp_"));
} }
/* abfd is a bfd containing n (or NULL) /* abfd is a bfd containing n (or NULL)
@ -460,7 +460,7 @@ auto_export (bfd *abfd, def_file *d, const char *n)
{ {
int i; int i;
struct exclude_list_struct *ex; struct exclude_list_struct *ex;
autofilter_entry_type *afptr; const autofilter_entry_type *afptr;
const char * libname = 0; const char * libname = 0;
if (abfd && abfd->my_archive) if (abfd && abfd->my_archive)
libname = lbasename (abfd->my_archive->filename); libname = lbasename (abfd->my_archive->filename);
@ -619,10 +619,11 @@ process_def_file (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_link_info *info)
/* We should not re-export imported stuff. */ /* We should not re-export imported stuff. */
{ {
char *name;
if (is_import (sn)) if (is_import (sn))
continue; continue;
char *name = xmalloc (strlen ("__imp_") + strlen (sn) + 1); name = xmalloc (strlen ("__imp_") + strlen (sn) + 1);
sprintf (name, "%s%s", "__imp_", sn); sprintf (name, "%s%s", "__imp_", sn);
blhe = bfd_link_hash_lookup (info->hash, name, blhe = bfd_link_hash_lookup (info->hash, name,
@ -1797,6 +1798,10 @@ make_tail (bfd *parent)
d7 = xmalloc (len); d7 = xmalloc (len);
id7->contents = d7; id7->contents = d7;
strcpy ((char *) d7, dll_filename); strcpy ((char *) d7, dll_filename);
/* If len was odd, the above
strcpy leaves behind an undefined byte. That is harmless,
but we set it to 0 just so the binary dumps are pretty. */
d7[len - 1] = 0;
bfd_set_symtab (abfd, symtab, symptr); bfd_set_symtab (abfd, symtab, symptr);
@ -1829,7 +1834,7 @@ make_tail (bfd *parent)
.short <hint> .short <hint>
.asciz "function" xlate? (add underscore, kill at) */ .asciz "function" xlate? (add underscore, kill at) */
static unsigned char jmp_ix86_bytes[] = static const unsigned char jmp_ix86_bytes[] =
{ {
0xff, 0x25, 0x00, 0x00, 0x00, 0x00, 0x90, 0x90 0xff, 0x25, 0x00, 0x00, 0x00, 0x00, 0x90, 0x90
}; };
@ -1841,7 +1846,7 @@ static unsigned char jmp_ix86_bytes[] =
nop nop
.dw __imp_function */ .dw __imp_function */
static unsigned char jmp_sh_bytes[] = static const unsigned char jmp_sh_bytes[] =
{ {
0x01, 0xd0, 0x02, 0x60, 0x2b, 0x40, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00 0x01, 0xd0, 0x02, 0x60, 0x2b, 0x40, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00
}; };
@ -1852,13 +1857,13 @@ static unsigned char jmp_sh_bytes[] =
jr $t0 jr $t0
nop */ nop */
static unsigned char jmp_mips_bytes[] = static const unsigned char jmp_mips_bytes[] =
{ {
0x00, 0x00, 0x08, 0x3c, 0x00, 0x00, 0x08, 0x8d, 0x00, 0x00, 0x08, 0x3c, 0x00, 0x00, 0x08, 0x8d,
0x08, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 0x08, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00
}; };
static unsigned char jmp_arm_bytes[] = static const unsigned char jmp_arm_bytes[] =
{ {
0x00, 0xc0, 0x9f, 0xe5, /* ldr ip, [pc] */ 0x00, 0xc0, 0x9f, 0xe5, /* ldr ip, [pc] */
0x00, 0xf0, 0x9c, 0xe5, /* ldr pc, [ip] */ 0x00, 0xf0, 0x9c, 0xe5, /* ldr pc, [ip] */
@ -1874,7 +1879,7 @@ make_one (def_file_export *exp, bfd *parent)
int len; int len;
char *oname; char *oname;
bfd *abfd; bfd *abfd;
unsigned char *jmp_bytes = NULL; const unsigned char *jmp_bytes = NULL;
int jmp_byte_count = 0; int jmp_byte_count = 0;
switch (pe_details->pe_arch) switch (pe_details->pe_arch)
@ -2029,7 +2034,8 @@ make_one (def_file_export *exp, bfd *parent)
} }
else else
{ {
len = strlen (exp->name) + 3; /* { short, asciz } */
len = 2 + strlen (exp->name) + 1;
if (len & 1) if (len & 1)
len++; len++;
bfd_set_section_size (abfd, id6, len); bfd_set_section_size (abfd, id6, len);