Fix freeing of link_info.hash
ld: * ldlang.c (lang_finish): Don't call bfd_link_hash_table_free here. (output_bfd_hash_table_free_fn): New variable. (open_output): Save the _bfd_link_hash_table_free function for the output_bfd into output_bfd_hash_table_free_fn. * ldmain.c (ld_cleanup): If set, call output_bfd_hash_table_free_fn on link_info.hash. * ldlang.h (output_bfd_hash_table_free_fn): Declare. ld/testsuite: * ld-mmix/wrap1.d, ld-mmix/wrap1a.s, ld-mmix/wrap1b.s, ld-mmix/wrap1c.s, ld-mmix/wrap2.d, ld-mmix/wrap3.d, ld-mmix/wrap3a.s, ld-mmix/wrap3b.s, ld-mmix/wrap4.d: New tests.
This commit is contained in:
parent
b1f02b89ed
commit
eae25ec577
10
ld/ChangeLog
10
ld/ChangeLog
@ -1,3 +1,13 @@
|
|||||||
|
2014-05-10 Hans-Peter Nilsson <hp@bitrange.com>
|
||||||
|
|
||||||
|
* ldlang.c (lang_finish): Don't call bfd_link_hash_table_free here.
|
||||||
|
(output_bfd_hash_table_free_fn): New variable.
|
||||||
|
(open_output): Save the _bfd_link_hash_table_free function for the
|
||||||
|
output_bfd into output_bfd_hash_table_free_fn.
|
||||||
|
* ldmain.c (ld_cleanup): If set, call output_bfd_hash_table_free_fn
|
||||||
|
on link_info.hash.
|
||||||
|
* ldlang.h (output_bfd_hash_table_free_fn): Declare.
|
||||||
|
|
||||||
2014-05-02 Alan Modra <amodra@gmail.com>
|
2014-05-02 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
* emultempl/metagelf.em: Update bfd target vector naming.
|
* emultempl/metagelf.em: Update bfd target vector naming.
|
||||||
|
16
ld/ldlang.c
16
ld/ldlang.c
@ -1237,7 +1237,6 @@ lang_init (void)
|
|||||||
void
|
void
|
||||||
lang_finish (void)
|
lang_finish (void)
|
||||||
{
|
{
|
||||||
bfd_link_hash_table_free (link_info.output_bfd, link_info.hash);
|
|
||||||
bfd_hash_table_free (&lang_definedness_table);
|
bfd_hash_table_free (&lang_definedness_table);
|
||||||
output_section_statement_table_free ();
|
output_section_statement_table_free ();
|
||||||
}
|
}
|
||||||
@ -3073,6 +3072,9 @@ lang_get_output_target (void)
|
|||||||
return default_target;
|
return default_target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Stashed function to free link_info.hash; see open_output. */
|
||||||
|
void (*output_bfd_hash_table_free_fn) (struct bfd_link_hash_table *);
|
||||||
|
|
||||||
/* Open the output file. */
|
/* Open the output file. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -3152,6 +3154,18 @@ open_output (const char *name)
|
|||||||
if (link_info.hash == NULL)
|
if (link_info.hash == NULL)
|
||||||
einfo (_("%P%F: can not create hash table: %E\n"));
|
einfo (_("%P%F: can not create hash table: %E\n"));
|
||||||
|
|
||||||
|
/* We want to please memory leak checkers by deleting link_info.hash.
|
||||||
|
We can't do it in lang_finish, as a bfd target may hold references to
|
||||||
|
symbols in this table and use them when their _bfd_write_contents
|
||||||
|
function is invoked, as part of bfd_close on the output_bfd. But,
|
||||||
|
output_bfd is deallocated at bfd_close, so we can't refer to
|
||||||
|
output_bfd after that time, and dereferencing it is needed to call
|
||||||
|
"bfd_link_hash_table_free". Smash this dependency deadlock and grab
|
||||||
|
the function pointer; arrange to call it on link_info.hash in
|
||||||
|
ld_cleanup. */
|
||||||
|
output_bfd_hash_table_free_fn
|
||||||
|
= link_info.output_bfd->xvec->_bfd_link_hash_table_free;
|
||||||
|
|
||||||
bfd_set_gp_size (link_info.output_bfd, g_switch_value);
|
bfd_set_gp_size (link_info.output_bfd, g_switch_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -518,6 +518,8 @@ extern lang_statement_list_type input_file_chain;
|
|||||||
extern int lang_statement_iteration;
|
extern int lang_statement_iteration;
|
||||||
extern struct asneeded_minfo **asneeded_list_tail;
|
extern struct asneeded_minfo **asneeded_list_tail;
|
||||||
|
|
||||||
|
extern void (*output_bfd_hash_table_free_fn) (struct bfd_link_hash_table *);
|
||||||
|
|
||||||
extern void lang_init
|
extern void lang_init
|
||||||
(void);
|
(void);
|
||||||
extern void lang_finish
|
extern void lang_finish
|
||||||
|
@ -171,6 +171,10 @@ ld_cleanup (void)
|
|||||||
#endif
|
#endif
|
||||||
if (output_filename && delete_output_file_on_failure)
|
if (output_filename && delete_output_file_on_failure)
|
||||||
unlink_if_ordinary (output_filename);
|
unlink_if_ordinary (output_filename);
|
||||||
|
|
||||||
|
/* See open_output in ldlang.c. */
|
||||||
|
if (output_bfd_hash_table_free_fn != NULL)
|
||||||
|
(*output_bfd_hash_table_free_fn) (link_info.hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If there's a BFD assertion, we'll notice and exit with an error
|
/* If there's a BFD assertion, we'll notice and exit with an error
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
2014-05-10 Hans-Peter Nilsson <hp@bitrange.com>
|
||||||
|
|
||||||
|
* ld-mmix/wrap1.d, ld-mmix/wrap1a.s, ld-mmix/wrap1b.s,
|
||||||
|
ld-mmix/wrap1c.s, ld-mmix/wrap2.d, ld-mmix/wrap3.d,
|
||||||
|
ld-mmix/wrap3a.s, ld-mmix/wrap3b.s, ld-mmix/wrap4.d: New
|
||||||
|
tests.
|
||||||
|
|
||||||
2014-05-09 H.J. Lu <hongjiu.lu@intel.com>
|
2014-05-09 H.J. Lu <hongjiu.lu@intel.com>
|
||||||
|
|
||||||
* ld-x86-64/tlsbin.dd: Replace data32 with data16.
|
* ld-x86-64/tlsbin.dd: Replace data32 with data16.
|
||||||
|
21
ld/testsuite/ld-mmix/wrap1.d
Normal file
21
ld/testsuite/ld-mmix/wrap1.d
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#source: start.s
|
||||||
|
#source: wrap1a.s
|
||||||
|
#source: wrap1b.s
|
||||||
|
#source: wrap1c.s
|
||||||
|
#ld: -m mmo --wrap deal
|
||||||
|
#as: -no-expand
|
||||||
|
#objdump: -d
|
||||||
|
|
||||||
|
.*: file format mmo
|
||||||
|
|
||||||
|
Disassembly of section \.text:
|
||||||
|
|
||||||
|
0+ <(_start|Main)>:
|
||||||
|
0: e3fd0001 setl \$253,0x1
|
||||||
|
4: f2000001 pushj \$0,8 <__wrap_deal>
|
||||||
|
|
||||||
|
0+8 <__wrap_deal>:
|
||||||
|
8: f0000001 jmp c <deal>
|
||||||
|
|
||||||
|
0+c <deal>:
|
||||||
|
c: fd000000 swym 0,0,0
|
2
ld/testsuite/ld-mmix/wrap1a.s
Normal file
2
ld/testsuite/ld-mmix/wrap1a.s
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
.text
|
||||||
|
pushj $0,deal
|
4
ld/testsuite/ld-mmix/wrap1b.s
Normal file
4
ld/testsuite/ld-mmix/wrap1b.s
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
.text
|
||||||
|
.globl __wrap_deal
|
||||||
|
__wrap_deal:
|
||||||
|
jmp __real_deal
|
4
ld/testsuite/ld-mmix/wrap1c.s
Normal file
4
ld/testsuite/ld-mmix/wrap1c.s
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
.text
|
||||||
|
.globl deal
|
||||||
|
deal:
|
||||||
|
swym 0
|
21
ld/testsuite/ld-mmix/wrap2.d
Normal file
21
ld/testsuite/ld-mmix/wrap2.d
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#source: start.s
|
||||||
|
#source: wrap1a.s
|
||||||
|
#source: wrap1b.s
|
||||||
|
#source: wrap1c.s
|
||||||
|
#ld: -m elf64mmix --wrap deal
|
||||||
|
#as: -no-expand
|
||||||
|
#objdump: -d
|
||||||
|
|
||||||
|
.*: file format elf64-mmix
|
||||||
|
|
||||||
|
Disassembly of section \.text:
|
||||||
|
|
||||||
|
0+ <(_start|Main)>:
|
||||||
|
0: e3fd0001 setl \$253,0x1
|
||||||
|
4: f2000001 pushj \$0,8 <__wrap_deal>
|
||||||
|
|
||||||
|
0+8 <__wrap_deal>:
|
||||||
|
8: f0000001 jmp c <deal>
|
||||||
|
|
||||||
|
0+c <deal>:
|
||||||
|
c: fd000000 swym 0,0,0
|
21
ld/testsuite/ld-mmix/wrap3.d
Normal file
21
ld/testsuite/ld-mmix/wrap3.d
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#source: start.s
|
||||||
|
#source: wrap3a.s
|
||||||
|
#source: wrap3b.s
|
||||||
|
#source: wrap1c.s
|
||||||
|
#ld: -m mmo
|
||||||
|
#as: -no-expand
|
||||||
|
#objdump: -d
|
||||||
|
|
||||||
|
.*: file format mmo
|
||||||
|
|
||||||
|
Disassembly of section \.text:
|
||||||
|
|
||||||
|
0+ <(_start|Main)>:
|
||||||
|
0: e3fd0001 setl \$253,0x1
|
||||||
|
4: f2000001 pushj \$0,8 <__wrap_deal>
|
||||||
|
|
||||||
|
0+8 <__wrap_deal>:
|
||||||
|
8: f0000001 jmp c <deal>
|
||||||
|
|
||||||
|
0+c <deal>:
|
||||||
|
c: fd000000 swym 0,0,0
|
2
ld/testsuite/ld-mmix/wrap3a.s
Normal file
2
ld/testsuite/ld-mmix/wrap3a.s
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
.text
|
||||||
|
pushj $0,__wrap_deal
|
4
ld/testsuite/ld-mmix/wrap3b.s
Normal file
4
ld/testsuite/ld-mmix/wrap3b.s
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
.text
|
||||||
|
.globl __wrap_deal
|
||||||
|
__wrap_deal:
|
||||||
|
jmp deal
|
21
ld/testsuite/ld-mmix/wrap4.d
Normal file
21
ld/testsuite/ld-mmix/wrap4.d
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#source: start.s
|
||||||
|
#source: wrap3a.s
|
||||||
|
#source: wrap3b.s
|
||||||
|
#source: wrap1c.s
|
||||||
|
#ld: -m elf64mmix
|
||||||
|
#as: -no-expand
|
||||||
|
#objdump: -d
|
||||||
|
|
||||||
|
.*: file format elf64-mmix
|
||||||
|
|
||||||
|
Disassembly of section \.text:
|
||||||
|
|
||||||
|
0+ <(_start|Main)>:
|
||||||
|
0: e3fd0001 setl \$253,0x1
|
||||||
|
4: f2000001 pushj \$0,8 <__wrap_deal>
|
||||||
|
|
||||||
|
0+8 <__wrap_deal>:
|
||||||
|
8: f0000001 jmp c <deal>
|
||||||
|
|
||||||
|
0+c <deal>:
|
||||||
|
c: fd000000 swym 0,0,0
|
Loading…
Reference in New Issue
Block a user