This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [rfa] make bfd_set_section_contents buffer param constant
- From: Andrew Cagney <ac131313 at redhat dot com>
- To: Andrew Cagney <ac131313 at redhat dot com>
- Cc: binutils at sources dot redhat dot com, gdb-patches at sources dot redhat dot com
- Date: Mon, 03 Nov 2003 09:45:02 -0500
- Subject: Re: [rfa] make bfd_set_section_contents buffer param constant
- References: <3FA29A42.5040302@redhat.com> <3FA29F1C.3020908@redhat.com>
Hello,
(almost obvious :-)
This makes the buffer parameter passed into bfd_set_section_contents constant. The only effect is +ve - remove the need to cast away "const" when calling the method with a constant buffer.
ok?
Andrew
Oops, I lied. It affect anything in binutils. This one bit of code in GDB will require a tweak.
xfer_fn = write ? bfd_set_section_contents : bfd_get_section_contents;
The attached is what I've checked in.
Andrew
2003-11-03 Andrew Cagney <cagney@redhat.com>
* section.c (bfd_set_section_contents): Make the "location" buffer
constant.
* bfd-in2.h: Re-generate.
Index: gdb/ChangeLog
2003-11-03 Andrew Cagney <cagney@redhat.com>
* exec.c (xfer_memory): Eliminate xfer_fn.
Index: bfd/bfd-in2.h
===================================================================
RCS file: /cvs/src/src/bfd/bfd-in2.h,v
retrieving revision 1.246
diff -u -r1.246 bfd-in2.h
--- bfd/bfd-in2.h 31 Oct 2003 05:32:45 -0000 1.246
+++ bfd/bfd-in2.h 3 Nov 2003 14:43:03 -0000
@@ -1483,8 +1483,8 @@
(bfd *abfd, asection *sec, bfd_size_type val);
bfd_boolean bfd_set_section_contents
- (bfd *abfd, asection *section, void *data, file_ptr offset,
- bfd_size_type count);
+ (bfd *abfd, asection *section, const void *data,
+ file_ptr offset, bfd_size_type count);
bfd_boolean bfd_get_section_contents
(bfd *abfd, asection *section, void *location, file_ptr offset,
Index: bfd/section.c
===================================================================
RCS file: /cvs/src/src/bfd/section.c,v
retrieving revision 1.64
diff -u -r1.64 section.c
--- bfd/section.c 31 Oct 2003 05:32:46 -0000 1.64
+++ bfd/section.c 3 Nov 2003 14:43:03 -0000
@@ -1132,8 +1132,8 @@
SYNOPSIS
bfd_boolean bfd_set_section_contents
- (bfd *abfd, asection *section, void *data, file_ptr offset,
- bfd_size_type count);
+ (bfd *abfd, asection *section, const void *data,
+ file_ptr offset, bfd_size_type count);
DESCRIPTION
Sets the contents of the section @var{section} in BFD
@@ -1161,7 +1161,7 @@
bfd_boolean
bfd_set_section_contents (bfd *abfd,
sec_ptr section,
- void *location,
+ const void *location,
file_ptr offset,
bfd_size_type count)
{
Index: gdb/exec.c
===================================================================
RCS file: /cvs/src/src/gdb/exec.c,v
retrieving revision 1.32
diff -u -r1.32 exec.c
--- gdb/exec.c 23 Oct 2003 03:01:54 -0000 1.32
+++ gdb/exec.c 3 Nov 2003 14:43:06 -0000
@@ -457,7 +457,6 @@
int res;
struct section_table *p;
CORE_ADDR nextsectaddr, memend;
- int (*xfer_fn) (bfd *, sec_ptr, void *, file_ptr, bfd_size_type);
asection *section = NULL;
if (len <= 0)
@@ -471,7 +470,6 @@
}
memend = memaddr + len;
- xfer_fn = write ? bfd_set_section_contents : bfd_get_section_contents;
nextsectaddr = memend;
for (p = target->to_sections; p < target->to_sections_end; p++)
@@ -484,8 +482,14 @@
if (memend <= p->endaddr)
{
/* Entire transfer is within this section. */
- res = xfer_fn (p->bfd, p->the_bfd_section, myaddr,
- memaddr - p->addr, len);
+ if (write)
+ res = bfd_set_section_contents (p->bfd, p->the_bfd_section,
+ myaddr, memaddr - p->addr,
+ len);
+ else
+ res = bfd_get_section_contents (p->bfd, p->the_bfd_section,
+ myaddr, memaddr - p->addr,
+ len);
return (res != 0) ? len : 0;
}
else if (memaddr >= p->endaddr)
@@ -497,8 +501,14 @@
{
/* This section overlaps the transfer. Just do half. */
len = p->endaddr - memaddr;
- res = xfer_fn (p->bfd, p->the_bfd_section, myaddr,
- memaddr - p->addr, len);
+ if (write)
+ res = bfd_set_section_contents (p->bfd, p->the_bfd_section,
+ myaddr, memaddr - p->addr,
+ len);
+ else
+ res = bfd_get_section_contents (p->bfd, p->the_bfd_section,
+ myaddr, memaddr - p->addr,
+ len);
return (res != 0) ? len : 0;
}
}