Skip to content

Commit aee7bc2

Browse files
nickcliftonshenki
authored andcommitted
Pass proper `bfd' argument to bfd_get_xxx functions
* bfd-in.h (bfd_get_section_name, bfd_get_section_vma, bfd_get_section_lma, bfd_get_section_alignment, bfd_get_section_flags, bfd_get_section_userdata): Rewrite macros in order to use the `bfd' argument. * bfd-in2.h: Regenerate. * elf-vxworks.c (elf_vxworks_finish_dynamic_entry): Pass proper `bfd' as the first argument for `bfd_get_section_alignment'. * elf32-arm.c (create_ifunc_sections): Likewise, for `bfd_set_section_alignment'. * elf32-m32r.c (m32r_elf_relocate_section): Likewise, for `bfd_get_section_name'. * elf32-microblaze.c (microblaze_elf_relocate_section): Likewise. * elf32-ppc.c (ppc_elf_size_dynamic_sections): Likewise. (ppc_elf_relocate_section): Likewise. * elf64-mmix.c (mmix_final_link_relocate): Likewise, for `bfd_get_section_vma'. * elf64-ppc.c (create_linkage_sections): Likewise, for `bfd_set_section_alignment'. * emultempl/m68hc1xelf.em (hook_in_stub): Pass proper `bfd' as the first argument for `bfd_get_section_name'. * config/tc-alpha.c (maybe_set_gp): Pass proper `bfd' as the first argument for `bfd_get_section_vma'. Upstream binutils commit a0f49396fd3a721a3bcd77457abeff75dd9564d9.
1 parent 1ffb381 commit aee7bc2

12 files changed

+76
-39
lines changed

bfd/bfd-in.h

+7-6
Original file line numberDiff line numberDiff line change
@@ -271,18 +271,19 @@ alent;
271271

272272
typedef struct bfd_section *sec_ptr;
273273

274-
#define bfd_get_section_name(bfd, ptr) ((ptr)->name + 0)
275-
#define bfd_get_section_vma(bfd, ptr) ((ptr)->vma + 0)
276-
#define bfd_get_section_lma(bfd, ptr) ((ptr)->lma + 0)
277-
#define bfd_get_section_alignment(bfd, ptr) ((ptr)->alignment_power + 0)
274+
#define bfd_get_section_name(bfd, ptr) ((void) bfd, (ptr)->name)
275+
#define bfd_get_section_vma(bfd, ptr) ((void) bfd, (ptr)->vma)
276+
#define bfd_get_section_lma(bfd, ptr) ((void) bfd, (ptr)->lma)
277+
#define bfd_get_section_alignment(bfd, ptr) ((void) bfd, \
278+
(ptr)->alignment_power)
278279
#define bfd_section_name(bfd, ptr) ((ptr)->name)
279280
#define bfd_section_size(bfd, ptr) ((ptr)->size)
280281
#define bfd_get_section_size(ptr) ((ptr)->size)
281282
#define bfd_section_vma(bfd, ptr) ((ptr)->vma)
282283
#define bfd_section_lma(bfd, ptr) ((ptr)->lma)
283284
#define bfd_section_alignment(bfd, ptr) ((ptr)->alignment_power)
284-
#define bfd_get_section_flags(bfd, ptr) ((ptr)->flags + 0)
285-
#define bfd_get_section_userdata(bfd, ptr) ((ptr)->userdata)
285+
#define bfd_get_section_flags(bfd, ptr) ((void) bfd, (ptr)->flags)
286+
#define bfd_get_section_userdata(bfd, ptr) ((void) bfd, (ptr)->userdata)
286287

287288
#define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0)
288289

bfd/bfd-in2.h

+7-6
Original file line numberDiff line numberDiff line change
@@ -278,18 +278,19 @@ alent;
278278

279279
typedef struct bfd_section *sec_ptr;
280280

281-
#define bfd_get_section_name(bfd, ptr) ((ptr)->name + 0)
282-
#define bfd_get_section_vma(bfd, ptr) ((ptr)->vma + 0)
283-
#define bfd_get_section_lma(bfd, ptr) ((ptr)->lma + 0)
284-
#define bfd_get_section_alignment(bfd, ptr) ((ptr)->alignment_power + 0)
281+
#define bfd_get_section_name(bfd, ptr) ((void) bfd, (ptr)->name)
282+
#define bfd_get_section_vma(bfd, ptr) ((void) bfd, (ptr)->vma)
283+
#define bfd_get_section_lma(bfd, ptr) ((void) bfd, (ptr)->lma)
284+
#define bfd_get_section_alignment(bfd, ptr) ((void) bfd, \
285+
(ptr)->alignment_power)
285286
#define bfd_section_name(bfd, ptr) ((ptr)->name)
286287
#define bfd_section_size(bfd, ptr) ((ptr)->size)
287288
#define bfd_get_section_size(ptr) ((ptr)->size)
288289
#define bfd_section_vma(bfd, ptr) ((ptr)->vma)
289290
#define bfd_section_lma(bfd, ptr) ((ptr)->lma)
290291
#define bfd_section_alignment(bfd, ptr) ((ptr)->alignment_power)
291-
#define bfd_get_section_flags(bfd, ptr) ((ptr)->flags + 0)
292-
#define bfd_get_section_userdata(bfd, ptr) ((ptr)->userdata)
292+
#define bfd_get_section_flags(bfd, ptr) ((void) bfd, (ptr)->flags)
293+
#define bfd_get_section_userdata(bfd, ptr) ((void) bfd, (ptr)->userdata)
293294

294295
#define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0)
295296

bfd/bfd-in2.h.orig

+35-6
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,6 @@ typedef struct bfd_section *sec_ptr;
293293

294294
#define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0)
295295

296-
#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma = (val)), ((ptr)->user_set_vma = TRUE), TRUE)
297-
#define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),TRUE)
298-
#define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE)
299296
/* Find the address one past the end of SEC. */
300297
#define bfd_get_section_limit(bfd, sec) \
301298
(((bfd)->direction != write_direction && (sec)->rawsize != 0 \
@@ -521,8 +518,6 @@ extern void warn_deprecated (const char *, const char *, int, const char *);
521518

522519
#define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char)
523520

524-
#define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = bool), TRUE)
525-
526521
extern bfd_boolean bfd_cache_close
527522
(bfd *abfd);
528523
/* NB: This declaration should match the autogenerated one in libbfd.h. */
@@ -980,7 +975,7 @@ bfd *bfd_openr (const char *filename, const char *target);
980975

981976
bfd *bfd_fdopenr (const char *filename, const char *target, int fd);
982977

983-
bfd *bfd_openstreamr (const char *, const char *, void *);
978+
bfd *bfd_openstreamr (const char * filename, const char * target, void * stream);
984979

985980
bfd *bfd_openr_iovec (const char *filename, const char *target,
986981
void *(*open_func) (struct bfd *nbfd,
@@ -1542,6 +1537,32 @@ struct relax_table {
15421537
int size;
15431538
};
15441539

1540+
/* Note: the following are provided as inline functions rather than macros
1541+
because not all callers use the return value. A macro implementation
1542+
would use a comma expression, eg: "((ptr)->foo = val, TRUE)" and some
1543+
compilers will complain about comma expressions that have no effect. */
1544+
static inline bfd_boolean
1545+
bfd_set_section_userdata (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, void * val)
1546+
{
1547+
ptr->userdata = val;
1548+
return TRUE;
1549+
}
1550+
1551+
static inline bfd_boolean
1552+
bfd_set_section_vma (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, bfd_vma val)
1553+
{
1554+
ptr->vma = ptr->lma = val;
1555+
ptr->user_set_vma = TRUE;
1556+
return TRUE;
1557+
}
1558+
1559+
static inline bfd_boolean
1560+
bfd_set_section_alignment (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, unsigned int val)
1561+
{
1562+
ptr->alignment_power = val;
1563+
return TRUE;
1564+
}
1565+
15451566
/* These sections are global, and are managed by BFD. The application
15461567
and target back end are not permitted to change the values in
15471568
these sections. New code should use the section_ptr macros rather
@@ -5502,6 +5523,14 @@ struct bfd
55025523
unsigned int selective_search : 1;
55035524
};
55045525

5526+
/* See note beside bfd_set_section_userdata. */
5527+
static inline bfd_boolean
5528+
bfd_set_cacheable (bfd * abfd, bfd_boolean val)
5529+
{
5530+
abfd->cacheable = val;
5531+
return TRUE;
5532+
}
5533+
55055534
typedef enum bfd_error
55065535
{
55075536
bfd_error_no_error = 0,

bfd/elf-vxworks.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* VxWorks support for ELF
2-
Copyright 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
2+
Copyright 2005, 2006, 2007, 2009, 2012 Free Software Foundation, Inc.
33
44
This file is part of BFD, the Binary File Descriptor library.
55
@@ -280,7 +280,8 @@ elf_vxworks_finish_dynamic_entry (bfd *output_bfd, Elf_Internal_Dyn *dyn)
280280
case DT_VX_WRS_TLS_DATA_ALIGN:
281281
sec = bfd_get_section_by_name (output_bfd, ".tls_data");
282282
dyn->d_un.d_val
283-
= (bfd_size_type)1 << bfd_get_section_alignment (abfd, sec);
283+
= (bfd_size_type)1 << bfd_get_section_alignment (output_bfd,
284+
sec);
284285
break;
285286

286287
case DT_VX_WRS_TLS_VARS_START:

bfd/elf32-arm.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -3132,7 +3132,7 @@ create_ifunc_sections (struct bfd_link_info *info)
31323132
s = bfd_make_section_with_flags (dynobj, ".iplt",
31333133
flags | SEC_READONLY | SEC_CODE);
31343134
if (s == NULL
3135-
|| !bfd_set_section_alignment (abfd, s, bed->plt_alignment))
3135+
|| !bfd_set_section_alignment (dynobj, s, bed->plt_alignment))
31363136
return FALSE;
31373137
htab->root.iplt = s;
31383138
}
@@ -3142,7 +3142,7 @@ create_ifunc_sections (struct bfd_link_info *info)
31423142
s = bfd_make_section_with_flags (dynobj, RELOC_SECTION (htab, ".iplt"),
31433143
flags | SEC_READONLY);
31443144
if (s == NULL
3145-
|| !bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
3145+
|| !bfd_set_section_alignment (dynobj, s, bed->s->log_file_align))
31463146
return FALSE;
31473147
htab->root.irelplt = s;
31483148
}

bfd/elf32-m32r.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3010,7 +3010,7 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
30103010
const char *name;
30113011

30123012
BFD_ASSERT (sec != NULL);
3013-
name = bfd_get_section_name (abfd, sec);
3013+
name = bfd_get_section_name (sec->owner, sec);
30143014

30153015
if ( strcmp (name, ".sdata") == 0
30163016
|| strcmp (name, ".sbss") == 0

bfd/elf32-microblaze.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* Xilinx MicroBlaze-specific support for 32-bit ELF
22
3-
Copyright 2009, 2010, 2011 Free Software Foundation, Inc.
3+
Copyright 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
44
55
This file is part of BFD, the Binary File Descriptor library.
66
@@ -839,7 +839,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
839839
/* Only relocate if the symbol is defined. */
840840
if (sec)
841841
{
842-
name = bfd_get_section_name (abfd, sec);
842+
name = bfd_get_section_name (sec->owner, sec);
843843

844844
if (strcmp (name, ".sdata2") == 0
845845
|| strcmp (name, ".sbss2") == 0)
@@ -868,7 +868,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
868868
bfd_get_filename (input_bfd),
869869
sym_name,
870870
microblaze_elf_howto_table[(int) r_type]->name,
871-
bfd_get_section_name (abfd, sec));
871+
bfd_get_section_name (sec->owner, sec));
872872
/*bfd_set_error (bfd_error_bad_value); ??? why? */
873873
ret = FALSE;
874874
continue;
@@ -884,7 +884,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
884884
/* Only relocate if the symbol is defined. */
885885
if (sec)
886886
{
887-
name = bfd_get_section_name (abfd, sec);
887+
name = bfd_get_section_name (sec->owner, sec);
888888

889889
if (strcmp (name, ".sdata") == 0
890890
|| strcmp (name, ".sbss") == 0)
@@ -913,7 +913,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
913913
bfd_get_filename (input_bfd),
914914
sym_name,
915915
microblaze_elf_howto_table[(int) r_type]->name,
916-
bfd_get_section_name (abfd, sec));
916+
bfd_get_section_name (sec->owner, sec));
917917
/*bfd_set_error (bfd_error_bad_value); ??? why? */
918918
ret = FALSE;
919919
continue;

bfd/elf32-ppc.c

+9-6
Original file line numberDiff line numberDiff line change
@@ -5800,7 +5800,8 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
58005800
{
58015801
/* Strip these too. */
58025802
}
5803-
else if (CONST_STRNEQ (bfd_get_section_name (dynobj, s), ".rela"))
5803+
else if (CONST_STRNEQ (bfd_get_section_name (htab->elf.dynobj, s),
5804+
".rela"))
58045805
{
58055806
if (s->size != 0)
58065807
{
@@ -7819,8 +7820,10 @@ ppc_elf_relocate_section (bfd *output_bfd,
78197820
unresolved_reloc = TRUE;
78207821
break;
78217822
}
7822-
BFD_ASSERT (strcmp (bfd_get_section_name (abfd, sec), ".got") == 0
7823-
|| strcmp (bfd_get_section_name (abfd, sec), ".cgot") == 0);
7823+
BFD_ASSERT (strcmp (bfd_get_section_name (sec->owner, sec),
7824+
".got") == 0
7825+
|| strcmp (bfd_get_section_name (sec->owner, sec),
7826+
".cgot") == 0);
78247827

78257828
addend -= sec->output_section->vma + sec->output_offset + 0x8000;
78267829
break;
@@ -7870,7 +7873,7 @@ ppc_elf_relocate_section (bfd *output_bfd,
78707873
}
78717874
addend -= SYM_VAL (sda);
78727875

7873-
name = bfd_get_section_name (abfd, sec->output_section);
7876+
name = bfd_get_section_name (output_bfd, sec->output_section);
78747877
if (! ((CONST_STRNEQ (name, ".sdata")
78757878
&& (name[6] == 0 || name[6] == '.'))
78767879
|| (CONST_STRNEQ (name, ".sbss")
@@ -7902,7 +7905,7 @@ ppc_elf_relocate_section (bfd *output_bfd,
79027905
}
79037906
addend -= SYM_VAL (sda);
79047907

7905-
name = bfd_get_section_name (abfd, sec->output_section);
7908+
name = bfd_get_section_name (output_bfd, sec->output_section);
79067909
if (! (CONST_STRNEQ (name, ".sdata2")
79077910
|| CONST_STRNEQ (name, ".sbss2")))
79087911
{
@@ -7931,7 +7934,7 @@ ppc_elf_relocate_section (bfd *output_bfd,
79317934
break;
79327935
}
79337936

7934-
name = bfd_get_section_name (abfd, sec->output_section);
7937+
name = bfd_get_section_name (output_bfd, sec->output_section);
79357938
if (((CONST_STRNEQ (name, ".sdata")
79367939
&& (name[6] == 0 || name[6] == '.'))
79377940
|| (CONST_STRNEQ (name, ".sbss")

bfd/elf64-mmix.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -1770,7 +1770,9 @@ mmix_final_link_relocate (reloc_howto_type *howto, asection *input_section,
17701770
first_global = 255;
17711771
else
17721772
{
1773-
first_global = bfd_get_section_vma (abfd, regsec) / 8;
1773+
first_global
1774+
= bfd_get_section_vma (input_section->output_section->owner,
1775+
regsec) / 8;
17741776
if (strcmp (bfd_get_section_name (symsec->owner, symsec),
17751777
MMIX_REG_CONTENTS_SECTION_NAME) == 0)
17761778
{

bfd/elf64-ppc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -4180,7 +4180,7 @@ create_linkage_sections (bfd *dynobj, struct bfd_link_info *info)
41804180
".eh_frame",
41814181
flags);
41824182
if (htab->glink_eh_frame == NULL
4183-
|| !bfd_set_section_alignment (abfd, htab->glink_eh_frame, 2))
4183+
|| !bfd_set_section_alignment (dynobj, htab->glink_eh_frame, 2))
41844184
return FALSE;
41854185
}
41864186

gas/config/tc-alpha.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -5294,7 +5294,7 @@ maybe_set_gp (asection *sec)
52945294

52955295
if (!sec)
52965296
return;
5297-
vma = bfd_get_section_vma (foo, sec);
5297+
vma = bfd_get_section_vma (sec->owner, sec);
52985298
if (vma && vma < alpha_gp_value)
52995299
alpha_gp_value = vma;
53005300
}

ld/emultempl/m68hc1xelf.em

+2-2
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,9 @@ hook_in_stub (struct hook_stub_info *info, lang_statement_union_type **lp)
204204

205205
case lang_input_section_enum:
206206
if (l->input_section.section == info->input_section
207-
|| strcmp (bfd_get_section_name (output_section,
207+
|| strcmp (bfd_get_section_name (l->input_section.section->owner,
208208
l->input_section.section),
209-
bfd_get_section_name (output_section,
209+
bfd_get_section_name (info->input_section->owner,
210210
info->input_section)) == 0)
211211
{
212212
/* We've found our section. Insert the stub immediately

0 commit comments

Comments
 (0)