This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Commit: Fix formatting in coff-i386.c
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Nick Clifton <nickc at redhat dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Fri, 18 Dec 2015 08:17:23 -0800
- Subject: Re: Commit: Fix formatting in coff-i386.c
- Authentication-results: sourceware.org; auth=none
- References: <87mvt8jgq7 dot fsf at redhat dot com>
On Fri, Dec 18, 2015 at 12:36 AM, Nick Clifton <nickc@redhat.com> wrote:
> Hi Guys,
>
> I was trying to bootstrap the mainline gcc sources yesterday using the
> latest binutils sources and I cam across this error:
>
> bfd/coff-i386.c: In function 'coff_i386_reloc':
> bfd/coff-i386.c:142:5: error: statement is indented as if it were guarded by... [-Werror=misleading-indentation]
> if (diff != 0)
> ^~
> bfd/coff-i386.c:133:3: note: ...this 'if' clause, but it is not
> if (reloc_entry->howto->type == R_IMAGEBASE
> ^~
>
> It turns out to be a simple case of mis-indentation of an if
> statement, so I am checking in the patch below to fix the problem.
>
> Cheers
> Nick
>
> bfd/ChangeLog
> 2015-12-18 Nick Clifton <nickc@redhat.com>
>
> * coff-i386.c (coff_i386_reloc): Fix formatting.
>
I checked in this to fix a similar issue in coff-x86_64.c.
H.J.
From c9f203207d418f72217f4bc0997acd809a0479ce Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 18 Dec 2015 08:15:27 -0800
Subject: [PATCH] Fix formatting in coff-x86_64.c
* coff-x86_64.c (coff_amd64_reloc): Fix formatting.
---
bfd/ChangeLog | 4 +++
bfd/coff-x86_64.c | 98 ++++++++++++++++++++++++++++---------------------------
2 files changed, 54 insertions(+), 48 deletions(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 72f99be..f81e90d 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,7 @@
+2015-12-18 H.J. Lu <hongjiu.lu@intel.com>
+
+ * coff-x86_64.c (coff_amd64_reloc): Fix formatting.
+
2015-12-18 Nick Clifton <nickc@redhat.com>
* coff-i386.c (coff_i386_reloc): Fix formatting.
diff --git a/bfd/coff-x86_64.c b/bfd/coff-x86_64.c
index 4e6420a..9d7c845 100644
--- a/bfd/coff-x86_64.c
+++ b/bfd/coff-x86_64.c
@@ -138,59 +138,61 @@ coff_amd64_reloc (bfd *abfd,
#define DOIT(x) \
x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask))
- if (diff != 0)
- {
- reloc_howto_type *howto = reloc_entry->howto;
- unsigned char *addr = (unsigned char *) data + reloc_entry->address;
-
- /* FIXME: We do not have an end address for data, so we cannot
- accurately range check any addresses computed against it.
- cf: PR binutils/17512: file: 1085-1761-0.004.
- For now we do the best that we can. */
- if (addr < (unsigned char *) data || addr > ((unsigned char *) data) + input_section->size)
+ if (diff != 0)
+ {
+ reloc_howto_type *howto = reloc_entry->howto;
+ unsigned char *addr = (unsigned char *) data + reloc_entry->address;
+
+ /* FIXME: We do not have an end address for data, so we cannot
+ accurately range check any addresses computed against it.
+ cf: PR binutils/17512: file: 1085-1761-0.004.
+ For now we do the best that we can. */
+ if (addr < (unsigned char *) data
+ || addr > ((unsigned char *) data) + input_section->size)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return bfd_reloc_notsupported;
+ }
+
+ switch (howto->size)
+ {
+ case 0:
+ {
+ char x = bfd_get_8 (abfd, addr);
+ DOIT (x);
+ bfd_put_8 (abfd, x, addr);
+ }
+ break;
+
+ case 1:
+ {
+ short x = bfd_get_16 (abfd, addr);
+ DOIT (x);
+ bfd_put_16 (abfd, (bfd_vma) x, addr);
+ }
+ break;
+
+ case 2:
{
- bfd_set_error (bfd_error_bad_value);
- return bfd_reloc_notsupported;
+ long x = bfd_get_32 (abfd, addr);
+ DOIT (x);
+ bfd_put_32 (abfd, (bfd_vma) x, addr);
}
+ break;
- switch (howto->size)
+ case 4:
{
- case 0:
- {
- char x = bfd_get_8 (abfd, addr);
- DOIT (x);
- bfd_put_8 (abfd, x, addr);
- }
- break;
-
- case 1:
- {
- short x = bfd_get_16 (abfd, addr);
- DOIT (x);
- bfd_put_16 (abfd, (bfd_vma) x, addr);
- }
- break;
-
- case 2:
- {
- long x = bfd_get_32 (abfd, addr);
- DOIT (x);
- bfd_put_32 (abfd, (bfd_vma) x, addr);
- }
- break;
- case 4:
- {
- long long x = bfd_get_64 (abfd, addr);
- DOIT (x);
- bfd_put_64 (abfd, (bfd_vma) x, addr);
- }
- break;
-
- default:
- bfd_set_error (bfd_error_bad_value);
- return bfd_reloc_notsupported;
+ long long x = bfd_get_64 (abfd, addr);
+ DOIT (x);
+ bfd_put_64 (abfd, (bfd_vma) x, addr);
}
- }
+ break;
+
+ default:
+ bfd_set_error (bfd_error_bad_value);
+ return bfd_reloc_notsupported;
+ }
+ }
/* Now let bfd_perform_relocation finish everything up. */
return bfd_reloc_continue;
--
2.5.0