Add support to readelf for the PT_OPENBSD_NOBTCFI segment type.

Message ID ZQxTtMITWftXrjRr@hydra
State Unresolved
Headers
Series Add support to readelf for the PT_OPENBSD_NOBTCFI segment type. |

Checks

Context Check Description
snail/binutils-gdb-check warning Git am fail log

Commit Message

Frederic Cambus Sept. 21, 2023, 2:31 p.m. UTC
  binutils * readelf.c (get_segment_type): Handle PT_OPENBSD_NOBTCFI segment type.
include  * elf/common.h (PT_OPENBSD_NOBTCFI): Define.
---
 binutils/ChangeLog   | 5 +++++
 binutils/readelf.c   | 1 +
 include/ChangeLog    | 4 ++++
 include/elf/common.h | 1 +
 4 files changed, 11 insertions(+)
  

Comments

Nick Clifton Sept. 27, 2023, 1:38 p.m. UTC | #1
Hi Frederic,

   Approved - please apply - but with one very small change:

>   #define PT_OPENBSD_WXNEEDED  (PT_LOOS + 0x5a3dbe7)  /* Program does W^X violations.  */
> +#define PT_OPENBSD_NOBTCFI   (PT_LOOS + 0x5a3dbe8)  /* no branch target CFI.  */
>   #define PT_OPENBSD_BOOTDATA  (PT_LOOS + 0x5a41be6)  /* Section for boot arguments.  */

Please could you use a capital letter at the start of the comment.  ie:

 > +#define PT_OPENBSD_NOBTCFI   (PT_LOOS + 0x5a3dbe8)  /* No branch target CFI.  */

Cheers
   Nick
  
Frederic Cambus Sept. 28, 2023, 11:05 a.m. UTC | #2
Hi Nick,

On Wed, Sep 27, 2023 at 02:38:25PM +0100, Nick Clifton wrote:
> Hi Frederic,
> 
>   Approved - please apply - but with one very small change:
> 
> >   #define PT_OPENBSD_WXNEEDED  (PT_LOOS + 0x5a3dbe7)  /* Program does W^X violations.  */
> > +#define PT_OPENBSD_NOBTCFI   (PT_LOOS + 0x5a3dbe8)  /* no branch target CFI.  */
> >   #define PT_OPENBSD_BOOTDATA  (PT_LOOS + 0x5a41be6)  /* Section for boot arguments.  */
> 
> Please could you use a capital letter at the start of the comment.  ie:
> 
> > +#define PT_OPENBSD_NOBTCFI   (PT_LOOS + 0x5a3dbe8)  /* No branch target CFI.  */

Thanks for the review. I don't have commit access, could you please
commit it for me?
  
Nick Clifton Sept. 28, 2023, 12:39 p.m. UTC | #3
Hi Frederic,

> Thanks for the review. I don't have commit access, could you please
> commit it for me?

Done.

Cheers
   Nick
  

Patch

diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index ac14aff1827..4e58cc2e3dd 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,8 @@ 
+2023-09-21  Frederic Cambus  <fred@statdns.com>
+
+	* readelf.c (get_segment_type): Handle PT_OPENBSD_NOBTCFI segment
+	type.
+
 2023-09-05  Nick Clifton  <nickc@redhat.com>
 
 	PR 30684
diff --git a/binutils/readelf.c b/binutils/readelf.c
index e9935c010cf..be2f3851c63 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -5082,6 +5082,7 @@  get_segment_type (Filedata * filedata, unsigned long p_type)
     case PT_OPENBSD_MUTABLE: return "OPENBSD_MUTABLE";
     case PT_OPENBSD_RANDOMIZE: return "OPENBSD_RANDOMIZE";
     case PT_OPENBSD_WXNEEDED: return "OPENBSD_WXNEEDED";
+    case PT_OPENBSD_NOBTCFI: return "OPENBSD_NOBTCFI";
     case PT_OPENBSD_BOOTDATA: return "OPENBSD_BOOTDATA";
 
     default:
diff --git a/include/ChangeLog b/include/ChangeLog
index eb54da44146..90eb51f9208 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,7 @@ 
+2023-09-21  Frederic Cambus  <fred@statdns.com>
+
+	* elf/common.h (PT_OPENBSD_NOBTCFI): Define.
+
 2023-08-02  Tom Tromey  <tromey@adacore.com>
 
 	* coff/x86_64.h (COFF_X86_64_H): Add include guard.
diff --git a/include/elf/common.h b/include/elf/common.h
index 932ea94e3ae..ad95dbc965f 100644
--- a/include/elf/common.h
+++ b/include/elf/common.h
@@ -495,6 +495,7 @@ 
 #define PT_OPENBSD_MUTABLE   (PT_LOOS + 0x5a3dbe5)  /* Like bss, but not immutable.  */
 #define PT_OPENBSD_RANDOMIZE (PT_LOOS + 0x5a3dbe6)  /* Fill with random data.  */
 #define PT_OPENBSD_WXNEEDED  (PT_LOOS + 0x5a3dbe7)  /* Program does W^X violations.  */
+#define PT_OPENBSD_NOBTCFI   (PT_LOOS + 0x5a3dbe8)  /* no branch target CFI.  */
 #define PT_OPENBSD_BOOTDATA  (PT_LOOS + 0x5a41be6)  /* Section for boot arguments.  */
 
 /* Mbind segments */