gcc2: Allow the user to build non-PI executables

This aligns legacy gcc with the changes to gcc4 committed in 4192115 and
the two subsequent commits.  It also disables legacy ld's default
behaviour of recursively resolving shared-library dependencies at link
time, preventing missing-library warnings during the build and aligning
ld's behaviour with that of more recent versions.

gcc2:

* CPP_SPEC: Replace non-existent command-line options with valid
  equivalents.
* CC1_SPEC: Remove non-existent "no-fpic" option; add "fno-pic" and
  "fno-PIC" as options that disable the generation of
  position-independent code; use "-fPIC" by default.
* LINK_SPEC: Pass "-shared" to the linker only if it was passed to gcc;
  output position-independent executables by default, exporting all
  symbols to match the behaviour of "-shared"; when building a
  dynamically linked executable, do not recursively add shared libraries
  as dependencies but do allow unresolved symbols in them; specify
  "-Bsymbolic" only when building a shared library.
* All: Wrap lines at 80 columns; use more compact notation where
  available.

ld:

* Do not recursively resolve shared-library dependencies when building
  an executable if the "--no-add-needed" and "--allow-shlib-undefined"
  options are in effect.  This effectively backports binutils commits
  8fbb09e and 4706eab.

Signed-off-by: Jérôme Duval <jerome.duval@gmail.com>
This commit is contained in:
Simon South
2015-10-30 13:28:32 -04:00
committed by Jérôme Duval
parent a0d6e40ddd
commit 465fb4d4a7
2 changed files with 17 additions and 4 deletions

View File

@@ -891,6 +891,13 @@ gld${EMULATION_NAME}_after_open (void)
&& (bfd_elf_get_dyn_lib_class (l->by) & DYN_AS_NEEDED) != 0)
continue;
/* Skip the lib if --no-add-needed and --allow-shlib-undefined
is in effect. */
if (l->by != NULL
&& link_info.unresolved_syms_in_shared_libs == RM_IGNORE
&& (bfd_elf_get_dyn_lib_class (l->by) & DYN_NO_ADD_NEEDED) != 0)
continue;
/* If we've already seen this file, skip it. */
for (ll = needed; ll != l; ll = ll->next)
if ((ll->by == NULL