aboutsummaryrefslogtreecommitdiff
path: root/bfd/cofflink.c
diff options
context:
space:
mode:
authorFred Fish <fnf@specifix.com>1997-05-24 15:30:55 +0000
committerFred Fish <fnf@specifix.com>1997-05-24 15:30:55 +0000
commite074d05eac56e4281f5954b7f9d9cc94a81a4cf4 (patch)
tree95a6330ef5d220e7498ade8466ee294f883ce9db /bfd/cofflink.c
parent61a5c2fdcfd9ff62c37fee9b8ae1f8b6b74e82f2 (diff)
downloadgdb-e074d05eac56e4281f5954b7f9d9cc94a81a4cf4.zip
gdb-e074d05eac56e4281f5954b7f9d9cc94a81a4cf4.tar.gz
gdb-e074d05eac56e4281f5954b7f9d9cc94a81a4cf4.tar.bz2
* libcoff-in.h (struct coff_final_link_info): Add boolean
global_to_static member for support of task linking. (_bfd_coff_write_task_globals): Add prototype. * libcoff.h: Regenerate. * coffcode.h (coff_write_object_contents): Use #ifdef to check RS6000COFF_C, to be consistent with all other uses in this file. * cofflink.c (_bfd_coff_final_link): If doing task linking, call _bfd_coff_write_task_globals. (_bfd_coff_link_input_bfd): If doing task linking, convert global functions to static. (_bfd_coff_write_global_sym): If doing task linking, convert global variables to static. (_bfd_coff_write_task_globals): New function. * coff-tic80.c (TIC80COFF): Define this instead of just TIC80. (C_AUTOARG): #undef since it clashes with C_UEXT. (C_LASTENT): #undef since it clashes with C_STATLAB. * coffcode.h (coff_write_object_contents): Use TIC80COFF rather than TIC80. (coff_slurp_symbol_table): Use C_SYSTEM. Hide C_AUTOARG use when TIC80COFF defined (clashes with C_UEXT). Explicitly recognize C_UEXT, C_STATLAB, and C_EXTLAB as unsupported. PR 12236
Diffstat (limited to 'bfd/cofflink.c')
-rw-r--r--bfd/cofflink.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/bfd/cofflink.c b/bfd/cofflink.c
index c721bdf..38a181f 100644
--- a/bfd/cofflink.c
+++ b/bfd/cofflink.c
@@ -838,6 +838,18 @@ _bfd_coff_final_link (abfd, info)
return false;
}
+ /* If doing task linking (ld --task-link) then make a pass through the
+ global symbols, writing out any that are defined, and making them
+ static. */
+ if (info->task_link)
+ {
+ finfo.failed = false;
+ coff_link_hash_traverse (coff_hash_table (info), _bfd_coff_write_task_globals,
+ (PTR) &finfo);
+ if (finfo.failed)
+ goto error_return;
+ }
+
/* Write out the global symbols. */
finfo.failed = false;
coff_link_hash_traverse (coff_hash_table (info), _bfd_coff_write_global_sym,
@@ -1604,6 +1616,12 @@ _bfd_coff_link_input_bfd (finfo, input_bfd)
finfo->last_file = isym;
}
+ /* If doing task linking, convert normal global function symbols to
+ static functions. */
+
+ if (finfo->info->task_link && isym.n_sclass == C_EXT)
+ isym.n_sclass = C_STAT;
+
/* Output the symbol. */
bfd_coff_swap_sym_out (output_bfd, (PTR) &isym, (PTR) outsym);
@@ -2290,6 +2308,18 @@ _bfd_coff_write_global_sym (h, data)
if (isym.n_sclass == C_NULL)
isym.n_sclass = C_EXT;
+ /* If doing task linking and this is the pass where we convert defined globals to
+ statics, then do that conversion now. If the symbol is not being converted,
+ just ignore it and it will be output during a later pass. */
+ if (finfo->global_to_static)
+ {
+ if (isym.n_sclass != C_EXT)
+ {
+ return true;
+ }
+ isym.n_sclass = C_STAT;
+ }
+
isym.n_numaux = h->numaux;
bfd_coff_swap_sym_out (output_bfd, (PTR) &isym, (PTR) finfo->outsyms);
@@ -2328,6 +2358,33 @@ _bfd_coff_write_global_sym (h, data)
return true;
}
+/* Write out task global symbols, converting them to statics. Called
+ via coff_link_hash_traverse. Calls bfd_coff_write_global_sym to do
+ the dirty work, if the symbol we are processing needs conversion. */
+
+boolean
+_bfd_coff_write_task_globals (h, data)
+ struct coff_link_hash_entry *h;
+ PTR data;
+{
+ struct coff_final_link_info *finfo = (struct coff_final_link_info *) data;
+ boolean rtnval = true;
+
+ if (h->indx < 0)
+ {
+ switch (h->root.type)
+ {
+ case bfd_link_hash_defined:
+ case bfd_link_hash_defweak:
+ finfo->global_to_static = true;
+ rtnval = _bfd_coff_write_global_sym (h, data);
+ finfo->global_to_static = false;
+ break;
+ }
+ }
+ return (rtnval);
+}
+
/* Handle a link order which is supposed to generate a reloc. */
boolean