aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPer Bothner <per@bothner.com>1991-11-12 02:46:26 +0000
committerPer Bothner <per@bothner.com>1991-11-12 02:46:26 +0000
commitff7ce1700bc0ddc7db549189edf043510440244b (patch)
tree9e01d90ffa15a1524139110c97fd71b01c789de9
parent6690d8299d8c6319ac05b6f1cb40a9deaf837bb9 (diff)
downloadgdb-ff7ce1700bc0ddc7db549189edf043510440244b.zip
gdb-ff7ce1700bc0ddc7db549189edf043510440244b.tar.gz
gdb-ff7ce1700bc0ddc7db549189edf043510440244b.tar.bz2
* aoutx.h (NAME(aout,find_nearest_line)): Handle the case
of two N_SO stabs, one for directory, and one for filename. * bfd-in.h (print_vma): Factor out duplicate definition. Exit a little more gracefully when malloc returns NULL. * libbfd.c: New function bfd_xmalloc (malloc wrapper). * opncls.c, syms.c, bout.c, aoutx.h: Replace malloc by bfd_xmalloc. * libbfd.h: Rre-generated due to libbfd.c update.
-rw-r--r--bfd/ChangeLog12
-rw-r--r--bfd/opncls.c64
2 files changed, 70 insertions, 6 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 30441ba..375cb0b 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,15 @@
+Mon Nov 11 18:36:47 1991 Per Bothner (bothner at cygnus.com)
+
+ * aoutx.h (NAME(aout,find_nearest_line)): Handle the case
+ of two N_SO stabs, one for directory, and one for filename.
+
+ * bfd-in.h (print_vma): Factor out duplicate definition.
+
+ Exit a little more gracefully when malloc returns NULL.
+ * libbfd.c: New function bfd_xmalloc (malloc wrapper).
+ * opncls.c, syms.c, bout.c, aoutx.h: Replace malloc by bfd_xmalloc.
+ * libbfd.h: Rre-generated due to libbfd.c update.
+
Sat Nov 9 13:45:01 1991 Fred Fish (fnf at cygnus.com)
* config/mt-m68k-elf: Define DEFAULT_VECTOR as elf_big_vec.
diff --git a/bfd/opncls.c b/bfd/opncls.c
index f4bedfe..9e096f4 100644
--- a/bfd/opncls.c
+++ b/bfd/opncls.c
@@ -20,8 +20,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* $Id$ */
-#include <sysdep.h>
#include "bfd.h"
+#include "sysdep.h"
#include "libbfd.h"
#include "obstack.h"
extern void bfd_cache_init();
@@ -31,7 +31,7 @@ FILE *bfd_open_file();
if we do that we can't use fcntl. */
-#define obstack_chunk_alloc malloc
+#define obstack_chunk_alloc bfd_xmalloc
#define obstack_chunk_free free
/* Return a new BFD. All BFD's are allocated through this routine. */
@@ -44,8 +44,11 @@ bfd *new_bfd()
if (!nbfd)
return 0;
- obstack_begin(&nbfd->memory, 128);
-
+ bfd_check_init();
+ obstack_begin((PTR)&nbfd->memory, 128);
+
+ nbfd->arch_info = &bfd_default_arch_struct;
+
nbfd->direction = no_direction;
nbfd->iostream = NULL;
nbfd->where = 0;
@@ -172,8 +175,12 @@ DEFUN(bfd_fdopenr,(filename, target, fd),
return NULL;
}
+#ifdef FASCIST_FDOPEN
+ nbfd->iostream = (char *) fdopen (fd, "r");
+#else
/* if the fd were open for read only, this still would not hurt: */
nbfd->iostream = (char *) fdopen (fd, "r+");
+#endif
if (nbfd->iostream == NULL) {
(void) obstack_free (&nbfd->memory, (PTR)0);
return NULL;
@@ -186,7 +193,8 @@ DEFUN(bfd_fdopenr,(filename, target, fd),
/* As a special case we allow a FD open for read/write to
be written through, although doing so requires that we end
the previous clause with a preposition. */
- switch (fdflags & O_ACCMODE) {
+ /* (O_ACCMODE) parens are to avoid Ultrix header file bug */
+ switch (fdflags & (O_ACCMODE)) {
case O_RDONLY: nbfd->direction = read_direction; break;
case O_WRONLY: nbfd->direction = write_direction; break;
case O_RDWR: nbfd->direction = both_direction; break;
@@ -287,7 +295,51 @@ DEFUN(bfd_close,(abfd),
chmod(abfd->filename,buf.st_mode | S_IXUSR | S_IXGRP | S_IXOTH);
}
(void) obstack_free (&abfd->memory, (PTR)0);
- /* FIXME, shouldn't we de-allocate the bfd as well? */
+ (void) free(abfd);
+ return true;
+}
+
+/*proto* bfd_close_all_done
+This function closes a BFD. It differs from @code{bfd_close} since it
+does not complete any pending operations. This routine would be used
+if the application had just used BFD for swapping and didn't want to
+use any of the writing code.
+
+If the created file is executable, then @code{chmod} is called to mark
+it as such.
+
+All memory attached to the BFD's obstacks is released.
+
+@code{true} is returned if all is ok, otherwise @code{false}.
+*; PROTO(boolean, bfd_close_all_done,(bfd *));
+*/
+
+boolean
+DEFUN(bfd_close_all_done,(abfd),
+ bfd *abfd)
+{
+ bfd_cache_close(abfd);
+
+ /* If the file was open for writing and is now executable,
+ make it so */
+ if (abfd->direction == write_direction
+ && abfd->flags & EXEC_P) {
+ struct stat buf;
+ stat(abfd->filename, &buf);
+#ifndef S_IXUSR
+#define S_IXUSR 0100 /* Execute by owner. */
+#endif
+#ifndef S_IXGRP
+#define S_IXGRP 0010 /* Execute by group. */
+#endif
+#ifndef S_IXOTH
+#define S_IXOTH 0001 /* Execute by others. */
+#endif
+
+ chmod(abfd->filename,buf.st_mode | S_IXUSR | S_IXGRP | S_IXOTH);
+ }
+ (void) obstack_free (&abfd->memory, (PTR)0);
+ (void) free(abfd);
return true;
}