aboutsummaryrefslogtreecommitdiff
path: root/ld/emultempl
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2006-09-16 18:12:17 +0000
committerNick Clifton <nickc@redhat.com>2006-09-16 18:12:17 +0000
commit0112cd268b205d8176b8b4d00988a334822956cf (patch)
tree67d11340ff93c7dbc29c8917bc03d9d24555f43d /ld/emultempl
parent4fa3602bd53183badf1d259128a5f951f32db8cb (diff)
downloadgdb-0112cd268b205d8176b8b4d00988a334822956cf.zip
gdb-0112cd268b205d8176b8b4d00988a334822956cf.tar.gz
gdb-0112cd268b205d8176b8b4d00988a334822956cf.tar.bz2
* bfd-in.h (STRING_AND_COMMA): New macro. Takes one constant string as its
argument and emits the string followed by a comma and then the length of the string. (CONST_STRNEQ): New macro. Checks to see if a variable string has a constant string as its initial characters. (CONST_STRNCPY): New macro. Copies a constant string to the start of a variable string. * bfd-in2.h: Regenerate. * <remainign files>: Make use of the new macros.
Diffstat (limited to 'ld/emultempl')
-rw-r--r--ld/emultempl/aix.em4
-rw-r--r--ld/emultempl/beos.em19
-rw-r--r--ld/emultempl/elf32.em19
-rw-r--r--ld/emultempl/pe.em5
-rw-r--r--ld/emultempl/sunos.em14
-rw-r--r--ld/emultempl/xtensaelf.em7
6 files changed, 33 insertions, 35 deletions
diff --git a/ld/emultempl/aix.em b/ld/emultempl/aix.em
index d525edd..a85f7d0 100644
--- a/ld/emultempl/aix.em
+++ b/ld/emultempl/aix.em
@@ -10,7 +10,7 @@ cat >e${EMULATION_NAME}.c <<EOF
/* AIX emulation code for ${EMULATION_NAME}
Copyright 1991, 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
- 2003, 2004, 2005
+ 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
Written by Steve Chamberlain <sac@cygnus.com>
AIX support by Ian Lance Taylor <ian@cygnus.com>
@@ -268,7 +268,7 @@ gld${EMULATION_NAME}_parse_args (int argc, char **argv)
if (indx == 0)
indx = 1;
- if (indx < argc && strncmp (argv[indx], "-b", 2) == 0)
+ if (indx < argc && CONST_STRNEQ (argv[indx], "-b"))
{
char *s;
diff --git a/ld/emultempl/beos.em b/ld/emultempl/beos.em
index 220ba59..adb5dfb 100644
--- a/ld/emultempl/beos.em
+++ b/ld/emultempl/beos.em
@@ -8,7 +8,7 @@ fi
cat >e${EMULATION_NAME}.c <<EOF
/* This file is part of GLD, the Gnu Linker.
Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
- 2005 Free Software Foundation, Inc.
+ 2005, 2006 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -452,16 +452,15 @@ sort_by_section_name (const void *a, const void *b)
const lang_statement_union_type *const *rb = b;
int i;
i = strcmp ((*ra)->input_section.section->name,
- (*rb)->input_section.section->name);
-/* this is a hack to make .stab and .stabstr last, so we don't have
- to fix strip/objcopy for .reloc sections.
- FIXME stripping images with a .rsrc section still needs to be fixed */
- if ( i != 0)
+ (*rb)->input_section.section->name);
+ /* This is a hack to make .stab and .stabstr last, so we don't have
+ to fix strip/objcopy for .reloc sections.
+ FIXME stripping images with a .rsrc section still needs to be fixed. */
+ if (i != 0)
{
- if ((strncmp ((*ra)->input_section.section->name, ".stab", 5) == 0)
- && (strncmp ((*rb)->input_section.section->name, ".stab", 5) != 0))
+ if ((CONST_STRNEQ ((*ra)->input_section.section->name, ".stab"))
+ && (! CONST_STRNEQ ((*rb)->input_section.section->name, ".stab")))
return 1;
- return i;
}
return i;
}
@@ -534,7 +533,7 @@ sort_sections (lang_statement_union_type *s)
{
/* Is this the .idata section? */
if (sec->spec.name != NULL
- && strncmp (sec->spec.name, ".idata", 6) == 0)
+ && CONST_STRNEQ (sec->spec.name, ".idata"))
{
/* Sort the children. We want to sort any objects in
the same archive. In order to handle the case of
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 38bceaa..3350ac0 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -365,7 +365,7 @@ case ${target} in
struct bfd_link_needed_list *l;
for (l = needed; l != NULL; l = l->next)
- if (strncmp (l->name, "libc.so", 7) == 0)
+ if (CONST_STRNEQ (l->name, "libc.so"))
break;
if (l == NULL)
{
@@ -698,7 +698,7 @@ gld${EMULATION_NAME}_parse_ld_so_conf
if (p[0] == '\0')
continue;
- if (!strncmp (p, "include", 7) && (p[7] == ' ' || p[7] == '\t'))
+ if (CONST_STRNEQ (p, "include") && (p[7] == ' ' || p[7] == '\t'))
{
char *dir, c;
p += 8;
@@ -1326,7 +1326,7 @@ output_rel_find (asection *sec, int isdyn)
lookup = lookup->next)
{
if (lookup->constraint != -1
- && strncmp (".rel", lookup->name, 4) == 0)
+ && CONST_STRNEQ (lookup->name, ".rel"))
{
int lookrela = lookup->name[4] == 'a';
@@ -1435,7 +1435,7 @@ gld${EMULATION_NAME}_place_orphan (asection *s)
default:
break;
}
- else if (strncmp (secname, ".rel", 4) == 0)
+ else if (CONST_STRNEQ (secname, ".rel"))
{
secname = secname[4] == 'a' ? ".rela.dyn" : ".rel.dyn";
isdyn = 1;
@@ -1483,7 +1483,7 @@ gld${EMULATION_NAME}_place_orphan (asection *s)
sections into the .text section to get them out of the way. */
if (link_info.executable
&& ! link_info.relocatable
- && strncmp (secname, ".gnu.warning.", sizeof ".gnu.warning." - 1) == 0
+ && CONST_STRNEQ (secname, ".gnu.warning.")
&& hold[orphan_text].os != NULL)
{
lang_add_section (&hold[orphan_text].os->children, s,
@@ -1502,7 +1502,7 @@ gld${EMULATION_NAME}_place_orphan (asection *s)
;
else if ((s->flags & SEC_LOAD) != 0
&& ((iself && sh_type == SHT_NOTE)
- || (!iself && strncmp (secname, ".note", 5) == 0)))
+ || (!iself && CONST_STRNEQ (secname, ".note"))))
place = &hold[orphan_interp];
else if ((s->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0)
place = &hold[orphan_bss];
@@ -1511,7 +1511,7 @@ gld${EMULATION_NAME}_place_orphan (asection *s)
else if ((s->flags & SEC_READONLY) == 0)
place = &hold[orphan_data];
else if (((iself && (sh_type == SHT_RELA || sh_type == SHT_REL))
- || (!iself && strncmp (secname, ".rel", 4) == 0))
+ || (!iself && CONST_STRNEQ (secname, ".rel")))
&& (s->flags & SEC_LOAD) != 0)
place = &hold[orphan_rel];
else if ((s->flags & SEC_CODE) == 0)
@@ -1871,15 +1871,16 @@ EOF
fi
cat >>e${EMULATION_NAME}.c <<EOF
- else if (strncmp (optarg, "max-page-size=", 14) == 0)
+ else if (CONST_STRNEQ (optarg, "max-page-size="))
{
char *end;
+
config.maxpagesize = strtoul (optarg + 14, &end, 0);
if (*end)
einfo (_("%P%F: invalid maxium page size \`%s'\n"),
optarg + 14);
}
- else if (strncmp (optarg, "common-page-size=", 17) == 0)
+ else if (CONST_STRNEQ (optarg, "common-page-size="))
{
char *end;
config.commonpagesize = strtoul (optarg + 17, &end, 0);
diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em
index 0e75e18..fa4cafe 100644
--- a/ld/emultempl/pe.em
+++ b/ld/emultempl/pe.em
@@ -925,8 +925,7 @@ pe_find_data_imports (void)
for (i = 0; i < nsyms; i++)
{
- if (memcmp (symbols[i]->name, "__head_",
- sizeof ("__head_") - 1))
+ if (! CONST_STRNEQ (symbols[i]->name, "__head_"))
continue;
if (pe_dll_extra_pe_debug)
@@ -1060,7 +1059,7 @@ gld_${EMULATION_NAME}_after_open (void)
{
if (strcmp (sec->name, ".idata\$2") == 0)
idata2 = 1;
- if (strncmp (sec->name, ".idata\$", 7) == 0)
+ if (CONST_STRNEQ (sec->name, ".idata\$"))
is_imp = 1;
reloc_count += sec->reloc_count;
}
diff --git a/ld/emultempl/sunos.em b/ld/emultempl/sunos.em
index a480558..4fbe108 100644
--- a/ld/emultempl/sunos.em
+++ b/ld/emultempl/sunos.em
@@ -10,7 +10,7 @@ cat >e${EMULATION_NAME}.c <<EOF
/* SunOS emulation code for ${EMULATION_NAME}
Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
- 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
Written by Steve Chamberlain <sac@cygnus.com>
SunOS shared library support by Ian Lance Taylor <ian@cygnus.com>
@@ -160,7 +160,7 @@ gld${EMULATION_NAME}_find_so (lang_input_statement_type *inp)
|| ! inp->dynamic)
return;
- ASSERT (strncmp (inp->local_sym_name, "-l", 2) == 0);
+ ASSERT (CONST_STRNEQ (inp->local_sym_name, "-l"));
for (search = search_head; search != NULL; search = search->next)
{
@@ -273,7 +273,7 @@ gld${EMULATION_NAME}_search_dir
const char *s;
int found_maj, found_min;
- if (strncmp (entry->d_name, "lib", 3) != 0
+ if (! CONST_STRNEQ (entry->d_name, "lib")
|| strncmp (entry->d_name + 3, filename, len) != 0)
continue;
@@ -288,7 +288,7 @@ gld${EMULATION_NAME}_search_dir
native linker does not. This is more convenient for packages
which just generate .so files for shared libraries, as on ELF
systems. */
- if (strncmp (entry->d_name + 3 + len, ".so", 3) != 0)
+ if (! CONST_STRNEQ (entry->d_name + 3 + len, ".so"))
continue;
if (entry->d_name[6 + len] == '\0')
;
@@ -400,7 +400,7 @@ gld${EMULATION_NAME}_after_open (void)
if (global_found)
continue;
- if (strncmp (lname, "-l", 2) != 0)
+ if (! CONST_STRNEQ (lname, "-l"))
{
bfd *abfd;
@@ -586,7 +586,7 @@ gld${EMULATION_NAME}_check_needed (lang_input_statement_type *s)
{
if (s->filename == NULL)
return;
- if (strncmp (global_needed->name, "-l", 2) != 0)
+ if (! CONST_STRNEQ (global_needed->name, "-l"))
{
if (strcmp (s->filename, global_needed->name) == 0)
global_found = TRUE;
@@ -605,7 +605,7 @@ gld${EMULATION_NAME}_check_needed (lang_input_statement_type *s)
else
++sname;
- if (strncmp (sname, "lib", 3) != 0)
+ if (! CONST_STRNEQ (sname, "lib"))
return;
sname += 3;
diff --git a/ld/emultempl/xtensaelf.em b/ld/emultempl/xtensaelf.em
index 1135d27..bbee546 100644
--- a/ld/emultempl/xtensaelf.em
+++ b/ld/emultempl/xtensaelf.em
@@ -267,8 +267,7 @@ replace_instruction_table_sections (bfd *abfd, asection *sec)
insn_sec_name = INSN_SEC_BASE_NAME;
prop_sec_name = PROP_SEC_BASE_NAME;
}
- else if (strncmp (sec_name, LINKONCE_SEC_OLD_TEXT_BASE_NAME,
- strlen (LINKONCE_SEC_OLD_TEXT_BASE_NAME)) == 0)
+ else if (CONST_STRNEQ (sec_name, LINKONCE_SEC_OLD_TEXT_BASE_NAME))
{
insn_sec_name = sec_name;
owned_prop_sec_name = (char *) xmalloc (strlen (sec_name) + 20);
@@ -1207,9 +1206,9 @@ is_inconsistent_linkonce_section (asection *sec)
return FALSE;
/* Check if this is an Xtensa property section. */
- if (strncmp (sec_name + linkonce_len, "p.", 2) == 0)
+ if (CONST_STRNEQ (sec_name + linkonce_len, "p."))
name = sec_name + linkonce_len + 2;
- else if (strncmp (sec_name + linkonce_len, "prop.", 5) == 0)
+ else if (CONST_STRNEQ (sec_name + linkonce_len, "prop."))
name = strchr (sec_name + linkonce_len + 5, '.') + 1;
if (name)