diff options
author | Nick Clifton <nickc@redhat.com> | 2020-10-16 11:37:26 +0100 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2020-10-16 11:37:26 +0100 |
commit | 23ae20f5e3afeeab9aa616c63ab3b357668476d5 (patch) | |
tree | 77fe952d842fc8b8f4a0efccbc006686a3b05e77 /ld/ldmain.c | |
parent | 472d09c18a750f483ad974991f4f35ede3dfb10b (diff) | |
download | gdb-23ae20f5e3afeeab9aa616c63ab3b357668476d5.zip gdb-23ae20f5e3afeeab9aa616c63ab3b357668476d5.tar.gz gdb-23ae20f5e3afeeab9aa616c63ab3b357668476d5.tar.bz2 |
Add a new option to the linker: --error-handling-script=<NAME>. Run the script <NAME> if an undefined symbol or unfound library error is encountered.
PR 26626
* ldmain.c (undefined_symbol): If an error handlign script is
available, call it.
* ldfile.c (error_handling_script): Declare.
(ldfile_open_file): If a library cannot be found and an error
handling script is available, call it.
* ldmain.h (error_handling_script): Prototype.
* ldlex.h (OPTION_ERROR_HANDLING_SCRIPT): Define.
* lexsup.c (ld_options): Add --error-handling-script.
(parse_args): Add support for --errror-handling-script.
* ld.texi: Document the new feature.
* configure.ac: Add --error-handling-script option to disable
support for the new feature.
* NEWS: Mention the new feature.
* config.in: Regenerate.
* configure: Regenerate.
Diffstat (limited to 'ld/ldmain.c')
-rw-r--r-- | ld/ldmain.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/ld/ldmain.c b/ld/ldmain.c index 08be903..cdb4fe5 100644 --- a/ld/ldmain.c +++ b/ld/ldmain.c @@ -1382,6 +1382,10 @@ warning_find_reloc (bfd *abfd, asection *sec, void *iarg) free (relpp); } +#if SUPPORT_ERROR_HANDLING_SCRIPT +char * error_handling_script = NULL; +#endif + /* This is called when an undefined symbol is found. */ static void @@ -1419,6 +1423,40 @@ undefined_symbol (struct bfd_link_info *info, error_name = xstrdup (name); } +#if SUPPORT_ERROR_HANDLING_SCRIPT + if (error_handling_script != NULL + && error_count < MAX_ERRORS_IN_A_ROW) + { + char * argv[4]; + const char * res; + int status, err; + + argv[0] = error_handling_script; + argv[1] = "missing-symbol"; + argv[2] = (char *) name; + argv[3] = NULL; + + if (verbose) + einfo (_("%P: About to run error handling script '%s' with arguments: '%s' '%s'\n"), + argv[0], argv[1], argv[2]); + + res = pex_one (PEX_SEARCH, error_handling_script, argv, + N_("error handling script"), + NULL /* Send stdout to random, temp file. */, + NULL /* Write to stderr. */, + &status, &err); + if (res != NULL) + { + einfo (_("%P: Failed to run error handling script '%s', reason: "), + error_handling_script); + /* FIXME: We assume here that errrno == err. */ + perror (res); + } + /* We ignore the return status of the script and + carry on to issue the normal error message. */ + } +#endif /* SUPPORT_ERROR_HANDLING_SCRIPT */ + if (section != NULL) { if (error_count < MAX_ERRORS_IN_A_ROW) |