aboutsummaryrefslogtreecommitdiff
path: root/binutils/arsup.c
AgeCommit message (Collapse)AuthorFilesLines
2024-01-04Update year range in copyright notice of binutils filesAlan Modra1-1/+1
Adds two new external authors to etc/update-copyright.py to cover bfd/ax_tls.m4, and adds gprofng to dirs handled automatically, then updates copyright messages as follows: 1) Update cgen/utils.scm emitted copyrights. 2) Run "etc/update-copyright.py --this-year" with an extra external author I haven't committed, 'Kalray SA.', to cover gas testsuite files (which should have their copyright message removed). 3) Build with --enable-maintainer-mode --enable-cgen-maint=yes. 4) Check out */po/*.pot which we don't update frequently.
2023-01-31PR 30060, ASAN error in bfd_cache_closeAlan Modra1-2/+3
After bfd_close nothing should access bfd memory. Now that bfd_close always tidies up even after an error, attempting to tidy the cached bfd list by calling bfd_cache_close is wrong and not needed. PR 30060 * ar.c (remove_output): Don't call bfd_cache_close. (output_bfd): Delete. * arsup.c (ar_end): Call bfd_close_all_done, not bfd_cache_close.
2023-01-01Update year range in copyright notice of binutils filesAlan Modra1-1/+1
The newer update-copyright.py fixes file encoding too, removing cr/lf on binutils/bfdtest2.c and ld/testsuite/ld-cygwin/exe-export.exp, and embedded cr in binutils/testsuite/binutils-all/ar.exp string match.
2022-01-02Update year range in copyright notice of binutils filesAlan Modra1-1/+1
The result of running etc/update-copyright.py --this-year, fixing all the files whose mode is changed by the script, plus a build with --enable-maintainer-mode --enable-cgen-maint=yes, then checking out */po/*.pot which we don't update frequently. The copy of cgen was with commit d1dd5fcc38ead reverted as that commit breaks building of bfp opcodes files.
2021-04-19Fix a problem running the archiver program in MRI mode on archives ↵Nick Clifton1-0/+4
containing LTO compiled objects. PR 21702 * arsup.c (ar_addmod): Enable plugin support, if available.
2021-03-31Use bool in binutilsAlan Modra1-4/+4
* sysdep.h (POISON_BFD_BOOLEAN): Define. * addr2line.c, * ar.c, * arsup.c, * bfdtest2.c, * binemul.c, * binemul.h, * bucomm.c, * bucomm.h, * budbg.h, * coffgrok.c, * debug.c, * debug.h, * dlltool.c, * dwarf.c, * dwarf.h, * elfedit.c, * emul_aix.c, * mclex.c, * nm.c, * objcopy.c, * objdump.c, * od-macho.c, * prdbg.c, * rdcoff.c, * rddbg.c, * readelf.c, * rename.c, * stabs.c, * strings.c, * windint.h, * windmc.c, * windmc.h, * windres.c, * winduni.c, * wrstabs.c: Replace bfd_boolean with bool, FALSE with false, and TRUE with true throughout.
2021-02-24Use make_tempname file descriptor in smart_renameAlan Modra1-4/+5
This patch makes use of the temp file descriptor in smart_rename rather than reopening the file. I don't believe there is a security issue in reopening the file, but this way is one less directory operation. The patch also attempts to preserve S_ISUID and S_ISGID. PR 27456 * bucomm.h (smart_rename): Update prototype. * rename.c (smart_rename): Add fromfd and preserve_dates params. Pass fromfd and target_stat to simple_copy. Call set_times when preserve_dates. (simple_copy): Accept fromfd rather than from filename. Add target_stat param. Rewind fromfd rather than opening. Open "to" file without O_CREAT. Try to preserve S_ISUID and S_ISGID. * ar.c (write_archive): Rename ofd to tmpfd. Dup tmpfd before closing output temp file, and pass tmpfd to smart_rename. * arsup.c (temp_fd): Rename from real_fd. (ar_save): Dup temp_fd and pass to smart_rename. * objcopy.c (strip_main, copy_main): Likewise, and pass preserve_dates.
2021-02-19binutils: Avoid renaming over existing filesSiddhesh Poyarekar1-12/+1
Renaming over existing files needs additional care to restore permissions and ownership, which may not always succeed. Additionally, other properties of the file such as extended attributes may be lost, making the operation flaky. For predictable results, resort to rename() only if the file does not exist, otherwise copy the file contents into the existing file. This ensures that no additional tricks are needed to retain file properties. This also allows dropping of the redundant set_times on the tmpfile in objcopy/strip since now we no longer rename over existing files. binutils/ * ar.c (write_archive): Remove TARGET_STAT. Adjust call to SMART_RENAME. * arsup.c (ar_save): Likewise. * objcopy (strip_main): Don't copy TMPFD. Don't set times on temporary file and adjust call to SMART_RENAME. (copy_main): Likewise. * rename.c [!S_ISLNK]: Remove definitions. (try_preserve_permissions): Remove function. (smart_rename): Remove FD, PRESERVE_DATES arguments. Use rename system call only if TO does not exist. * bucomm.h (smart_rename): Adjust declaration.
2021-02-05PR27345, binutils/arsup.c: lstat() not available on all targetsAlan Modra1-1/+1
We can just use stat here, the same as is done in ar.c:open_inarch. PR 27345 * arsup.c (ar_save): Use stat rather than lstat.
2021-02-03pr27270 and pr27284, ar segfaults and wrong file modeAlan Modra1-17/+29
PR 27270 PR 27284 PR 26945 * ar.c: Don't include libbfd.h. (write_archive): Replace xmalloc+strcpy with xstrdup. Use bfd_stat rather than fstat on iostream. Move stat and fd tests outside of _WIN32 ifdef. Delete skip_stat variable. * arsup.c (temp_name, real_ofd): New static variables. (ar_open): Use make_tempname and bfd_fdopenw. (ar_save): Adjust to suit ar_open changes. Move stat output of _WIN32 ifdef. * objcopy.c: Don't include libbfd.h. (copy_file): Use bfd_stat.
2021-01-01Update year range in copyright notice of binutils filesAlan Modra1-1/+1
2020-12-11Fix a build problem when using FreeBSD 12.Sebastian Huber1-1/+1
* ar.c (write_archive): Cast iostream pointer to FILE *. * arsup.c (ar_save): Likewise. * objcopy.c (copy_file): Likewise.
2020-12-07binutils: Make smart_rename safe tooSiddhesh Poyarekar1-1/+13
smart_rename is capable of handling symlinks by copying and it also tries to preserve ownership and permissions of files when they're overwritten during the rename. This is useful in objcopy where the file properties need to be preserved. However because smart_rename does this using file names, it leaves a race window between renames and permission fixes. This change removes this race window by using file descriptors from the original BFDs that were used to manipulate these files wherever possible. The file that is to be renamed is also passed as a file descriptor so that we use fchown/fchmod on the file descriptor, thus making sure that we only modify the file we have opened to write. Further, in case the file is to be overwritten (as is the case in ar or objcopy), the permissions that need to be restored are taken from the file descriptor that was opened for input so that integrity of the file status is maintained all the way through to the rename. binutils/ * rename.c * ar.c (write_archive) [!defined (_WIN32) || defined (__CYGWIN32__)]: Initialize TARGET_STAT and OFD to pass to SMART_RENAME. * arsup.c (ar_save) [defined (_WIN32) || defined (__CYGWIN32__)]: Likewise. * bucomm.h (smart_rename): Add new arguments to declaration. * objcopy.c (strip_main)[defined (_WIN32) || defined (__CYGWIN32__)]: Initialize COPYFD and pass to SMART_RENAME. (copy_main) [defined (_WIN32) || defined (__CYGWIN32__)]: Likewise. * rename.c (try_preserve_permissions): New function. (smart_rename): Use it and add new arguments.
2020-05-19Use bfd_get_filename throughout binutilsAlan Modra1-5/+5
* ar.c (map_over_members, get_pos_bfd, delete_members, move_members), (replace_members): Use bfd_get_filename rather than accessing bfd->filename directly. * arsup.c (map_over_list, ar_delete, ar_replace, ar_extract): Likewise. * binemul.c (do_ar_emul_append): Likewise. * coffgrok.c (coff_grok): Likewise.
2020-01-01Update year range in copyright notice of binutils filesAlan Modra1-1/+1
2019-06-10Tidy up ar_open by using asprintf to replace xmalloc and sprintf.Christos Zoulas1-2/+9
PR 24649 * arsup.c (ar_open): Use asprintf in place of xmalloc and sprintf.
2019-01-01Update year range in copyright notice of binutils filesAlan Modra1-1/+1
2018-05-30Add option to ar's 't' command to display the offset of elements within the ↵Ant Bikeneev1-1/+1
archive. PR 23107 * ar.c (display_offsets): New variable. (usage): Add description of 'O' operator. (decode_option): Handle 'O' operator. (print_descr): Pass display_offsets to print_arelt_descr. * arsup.c: Update call to printy_arelt_descr. * objdump.c: Likewise. * bucomm.c (print_arelt_descr): If offsets parameter is true then display offset of archive element within the archive. * bucomm.h: Update prototype for print_arelt_descr. * doc/binutils.texi: Update description of ar command. * NEWS: Mention the new feature. * testsuite/binutils-all/ar.exp: Add text of new feature.
2018-01-03Update year range in copyright notice of binutils filesAlan Modra1-1/+1
2017-08-02Add support for creating archives of slim-LTO modules using MRi script commands.Nick Clifton1-4/+9
PR 21702 * arsup.c (ar_addmod): Add plugin support for the MRI ADDMOD command.
2017-01-02Update year range in copyright notice of all files.Alan Modra1-1/+1
2016-01-01Copyright update for binutilsAlan Modra1-1/+1
2015-01-02ChangeLog rotatation and copyright year updateAlan Modra1-1/+1
2014-03-05Update copyright yearsAlan Modra1-1/+1
2013-10-01 * arsup.c (ar_save): Respect the deterministic setting whenNick Clifton1-2/+5
reading from an mri script. * ar.c (main): Set the default deterministic mode when reading from an mri script.
2009-09-02update copyright datesAlan Modra1-1/+1
2008-03-28Add support for thin archives.Nick Clifton1-1/+2
* bfd/archive.c (_bfd_find_nested_archive): New function. (get_extended_arelt_filename): Add origin parameter. (_bfd_generic_read_ar_hdr_mag): Deal with extended name combined with a file offset. (append_relative_path): New function. (_bfd_get_elt_at_filepos): Deal with external members and nested archives. (bfd_generic_openr_next_archived_file): Thin archives. (bfd_generic_archive_p): Recognize new magic string. (adjust_relative_path): New function. (_bfd_construct_extended_name_table): Construct extended names for thin archive members. (_bfd_write_archive_contents): Emit new magic string, skip copying files for thin archives. * bfd/bfd-in.h (bfd_is_thin_archive): New macro. * bfd/bfd.c (struct bfd): New fields for thin archives. * bfd/libbfd-in.h (struct areltdata): New field for thin archives. * bfd/opncls.c (bfd_close): Delete BFDs for nested archives. * binutils/ar.c (make_thin_archive): New global flag. (map_over_members): Deal with full pathnames in thin archives. (usage, main): Add 'T' option for building thin archives. (replace_members): Pass thin archive flag to ar_emul_append. * binutils/arsup.c (ar_open): Initialize new flag. * binutils/binemul.c (ar_emul_append): Add new parameter for flattening nested archives. (do_ar_emul_default_append): New function. (ar_emul_default_append): Factored out recursive code. * binutils/binemul.h (ar_emul_default_append): Add new parameter. (struct bin_emulation_xfer_struct): New parameter for ar_append. * binutils/dlltool.c (gen_lib_file): Initialize thin archive flag. * binutils/emul_aix.c (ar_emul_aix_internal): Add new flatten parameter, currently unimplemented. All callers changed. * binutils/objcopy.c (copy_archive): Preserve thin archive flag. * binutils/doc/binutils.texi: Update ar documentation. * binutils/testsuite/binutils-all/ar.exp: Add thin archive tests. * include/aout/ar.h (ARMAGT): New magic string for thin archives.
2007-07-05Change sources over to using GPLv3Nick Clifton1-2/+3
2007-06-27bfd/Alan Modra1-15/+15
* bfd.c (struct bfd): Rename "next" to "archive_next". * archive.c: Rename uses throughout file. * archive64.c: Likewise. * coff-rs6000.c: Likewise. * ecoff.c: Likewise. * som.c: Likewise. * bfd-in2.h: Regenerate. binutils/ * ar.c: Rename uses of bfd.next to bfd.archive_next throughout. * arsup.c: Likewise. * binemul.c: Likewise. * objcopy.c: Likewise. * dlltool.c: Likewise. ld/ * pe-dll.c: Rename uses of bfd.next to bfd.archive_next throughout.
2007-04-26bfd/Alan Modra1-3/+4
Many files: Include sysdep.h before bfd.h. * Makefile.am: Run "make dep-am". * Makefile.in: Regenerate. binutils/ * bucumm.h: Split off host dependencies to.. * sysdep.h: ..here. Many files: Include sysdep.h. Remove duplicate headers and reorder. * Makefile.am: Run "make dep-am". * Makefile.in: Regenerate. ld/ Many files: Include sysdep.h first. Remove duplicate headers. * Makefile.am: Run "make dep-am". * Makefile.in: Regenerate. opcodes/ * Makefile.am: Run "make dep-am". * Makefile.in: Regenerate. * ns32k-dis.c: Include sysdep.h first.
2005-05-08Update FSF addressNick Clifton1-1/+1
2005-04-29 * ar.c (mri_mode): Make static.Ben Elliston1-4/+4
* arsup.c (obfd, real_name, outfile): Likewise. * binemul.c (ar_emul_create): Remove unused function. (ar_emul_default_create): Likewise. * binemul.h (ar_emul_create): Remove declaration. (ar_emul_default_create): Likewise. (struct bin_emulation_xfer_struct): Remove ar_create member. * bucomm.c (report): Make static. * bucomm.h (report): Remove declaration. * cxxfilt.c (mbuffer): Make static. (main): Use unsigned ints for some loop control variables. * readelf.c: Make many global variables static. * size.c (berkeley_format): Make static. (long_options): Likewise. * emul_aix.c (bin_aix_emulation): Remove ar_emul_default_create structure initialiser. (bin_aix5_emulation): Likewise. * emul_vanilla.c (bin_vanilla_emulation): Likewise.
2005-03-03update copyright datesAlan Modra1-2/+2
2004-04-07 PR 86Alan Modra1-2/+2
* arsup.c (ar_save): Use smart_rename.
2004-02-15Use bfd_cache_close, instead of accessing bfd->iostream directly.Andrew Cagney1-1/+1
2003-10-27 * ChangeLog: Fix typos.Kazu Hirata1-1/+1
* ChangeLog-9197: Likewise. * ChangeLog-9899: Likewise. * NEWS: Likewise. * ar.c: Fix comment typos. * arsup.c: Likewise. * coffgrok.c: Likewise. * debug.c: Likewise. * debug.h: Likewise. * dlltool.c: Likewise. * ieee.c: Likewise. * nm.c: Likewise. * objdump.c: Likewise. * prdbg.c: Likewise. * readelf.c: Likewise. * resrc.c: Likewise. * sysinfo.y: Likewise. * windres.c: Likewise.
2003-09-14 * addr2line.c: Convert to ISO C90 prototypes, change PTR, removeAndreas Jaeger1-38/+20
unneeded (void *) casts. * ar.c: Likewise. * arlex.l: Likewise. * arparse.y: Likewise. * arsup.c: Likewise. * binemul.c: Likewise. * binemul.h: Likewise. * bucomm.c: Likewise. * bucomm.h: Likewise. * budbg.h: Likewise. * budemang.c: Likewise. * budemang.h: Likewise. * coffdump.c: Likewise. * coffgrok.c: Likewise. * cxxfilt.c: Likewise. * debug.c: Likewise. * debug.h: Likewise. * deflex.l: Likewise. * dlltool.c: Likewise. * dlltool.h: Likewise. * dllwrap.c: Likewise. * emul_aix.c: Likewise. * filemode.c: Likewise. * ieee.c: Likewise. * nlmconv.c: Likewise. * nlmconv.h: Likewise. * nlmheader.y: Likewise. * nm.c: Likewise. * prdbg.c: Likewise. * rclex.l: Likewise. * rcparse.y: Likewise. * rdcoff.c: Likewise. * rddbg.c: Likewise. * rename.c: Likewise. * resbin.c: Likewise. * rescoff.c: Likewise. * resrc.c: Likewise. * size.c: Likewise. * srconv.c: Likewise. * stabs.c: Likewise. * strings.c: Likewise. * sysdump.c: Likewise. * sysinfo.y: Likewise. * syslex.l: Likewise. * unwind-ia64.c: Likewise. * unwind-ia64.h: Likewise. * version.c: Likewise. * windres.c: Likewise. * windres.h: Likewise. * winduni.c: Likewise. * wrstabs.c: Likewise.
2002-11-30s/boolean/bfd_boolean/ s/true/TRUE/ s/false/FALSE/. SimplifyAlan Modra1-3/+3
comparisons of bfd_boolean vars with TRUE/FALSE. Formatting.
2002-05-27Fix transaltion problems.Nick Clifton1-237/+273
2002-05-26 * arsup.c: Remove ARGSUSED.Kazu Hirata1-1/+0
* debug.c: Likewise. * ieee.c: Likewise. * nlmconv.c: Likewise. * prdbg.c: Likewise. * stabs.c: Likewise. * wrstabs.c: Likewise.
2002-05-19 * addr2line.c: Fix formatting.Kazu Hirata1-23/+23
* ar.c: Likewise. * arsup.c: Likewise. * arsup.h: Likewise. * binemul.c: Likewise. * binemul.h: Likewise. * bucomm.c: Likewise. * coffdump.c: Likewise. * coffgrok.c: Likewise. * coffgrok.h: Likewise.
2001-11-05 * arlex.l: Accept `\' in filenames. Patch by <earl_chew@agilent.com>.Jakub Jelinek1-1/+2
* arsup.c (ar_open): Prepend tmp- to basename, not whole path.
2001-03-13Fix typos in ChangeLogs and update copyright noticesNick Clifton1-1/+1
2000-05-26Eli Zaretskii's DOSish file name patches.Alan Modra1-6/+9
1999-07-11 * Many files: Changes to avoid gcc warnings: Add ATTRIBUTE_UNUSEDIan Lance Taylor1-2/+3
as appropriate. Add variable initializations. Add casts. * objdump.c (disassemble_bytes): Change j to bfd_vma. * readelf.c (process_syminfo): Change i to unsigned int. (display_debug_info): Change abbrev_number to unsigned long. (process_mips_specific): Change fcnt to size_t.
1999-05-0319990502 sourceware importbinu_ss_19990502Richard Henderson1-0/+456