bfd: Externalize the bfd_set_gp_value function

Message ID 6c22e2c299c5126e43fe631aae80abbb85d33f5f.camel@vnet.ibm.com
State New
Headers show
Series
  • bfd: Externalize the bfd_set_gp_value function
Related show

Commit Message

Alan Modra via Binutils July 27, 2021, 3:34 p.m.
Externalize the bfd_set_gp_value function.

Hi,
  This change adds an external-visible wrapper for
the bfd_set_gp_value function.
This is a prerequisite for some gdb patches that allow
better handing of the .TOC. relocations as necessary
for the rs6000/powerpc64le target.

This patch includes updates to bfd.c to add the 
externally visible
wrapper, and the updated bfd-in2.h
as seen after rebuilding bfd with
--enable-maintainer-mode.

Credit and Thanks to Alan Modra for guidance
on what
to do and how to approach this.  That said, errors in
implementation are my own. :-)

OK for trunk?

Thanks
-Will

	yyyy-mm-dd  Will Schmidt  <will_schmidt@vnet.ibm.com>

	* bfd/bfd.c (bfd_set_gp_value):  New external visible
	wrapper for the internal _bfd_set_gp_value function.

	* bfd/bfd-in2.h: New prototype for bfd_set_gp_value.

Comments

Alan Modra via Binutils July 28, 2021, 4:09 a.m. | #1
Committed with a few tweaks, thanks.

-- 
Alan Modra
Australia Development Lab, IBM
Alan Modra via Binutils July 28, 2021, 6:41 a.m. | #2
On Wed, 2021-07-28 at 13:39 +0930, Alan Modra wrote:
> Committed with a few tweaks, thanks.

> 

Thanks!
-Will

Patch

diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 43d4ff0b925..aea35a5516a 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -7104,10 +7104,12 @@  bool bfd_set_start_address (bfd *abfd, bfd_vma vma);
 
 unsigned int bfd_get_gp_size (bfd *abfd);
 
 void bfd_set_gp_size (bfd *abfd, unsigned int i);
 
+void bfd_set_gp_value (bfd * abfd, bfd_vma v);
+
 bfd_vma bfd_scan_vma (const char *string, const char **end, int base);
 
 bool bfd_copy_private_header_data (bfd *ibfd, bfd *obfd);
 
 #define bfd_copy_private_header_data(ibfd, obfd) \
diff --git a/bfd/bfd.c b/bfd/bfd.c
index eb555ad5df2..4b70deb40a1 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -1858,10 +1858,28 @@  _bfd_set_gp_value (bfd *abfd, bfd_vma v)
     ecoff_data (abfd)->gp = v;
   else if (abfd->xvec->flavour == bfd_target_elf_flavour)
     elf_gp (abfd) = v;
 }
 
+/*
+FUNCTION
+	bfd_set_gp_value
+
+SYNOPSIS
+	void bfd_set_gp_value (bfd * abfd, bfd_vma v);
+
+DESCRIPTION
+	Allow external access to the fucntion to set the GP value.
+	This is specifically added for gdb-compile support.
+*/
+
+void
+bfd_set_gp_value (bfd *abfd, bfd_vma v)
+{
+        return _bfd_set_gp_value (abfd, v);
+}
+
 /*
 FUNCTION
 	bfd_scan_vma
 
 SYNOPSIS