[hjl@lucon.org: PATCH: Preserve e_flags.]

Michal Moskal malekith at pld.org.pl
Mon Dec 17 18:06:10 CET 2001


Hmm.. This fixes problem with chpax. Should I install it to our cvs or
we're downgrading?

----- Forwarded message from "H . J . Lu" <hjl at lucon.org> -----

Date: Sat, 15 Dec 2001 16:20:17 -0800
From: "H . J . Lu" <hjl at lucon.org>
To: Michal Moskal <malekith at pld.org.pl>
Cc: binutils at sourceware.cygnus.com
Subject: PATCH: Preserve e_flags.
User-Agent: Mutt/1.2.5i
X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/)
X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/)

On Sat, Dec 15, 2001 at 10:11:35AM -0800, H . J . Lu wrote:
> On Tue, Dec 11, 2001 at 03:53:20PM +0100, Michal Moskal wrote:
> > chpax is simple utility to be used with openwall linux kernel patch.
> > The patch disallows certain things, but some programs still need it.
> > chpax is used to set certain flags in elf file (e_flags field, PAGE_EXEC
> > is for instance 0x01).
> > (sorry if you already knew that... :)
> > 
> > And now the problem is that objcopy (and strip), does not copy e_flags
> > from one elf file to another.
> > 
> 

Here is a patch. Shouldn't we preserve e_flags?



H.J.
---
2001-12-15  H.J. Lu <hjl at gnu.org>

	* elf-bfd.h (_bfd_elf_copy_private_bfd_data): New. Prototype.

	* elf.c (_bfd_elf_copy_private_bfd_data): New. Copy e_flags in
	the ELF header.

	* elfxx-target.h (bfd_elfNN_bfd_copy_private_bfd_data): Defined
	to _bfd_elf_copy_private_bfd_data.

--- bfd/elf-bfd.h.header	Sat Dec 15 09:30:02 2001
+++ bfd/elf-bfd.h	Sat Dec 15 16:00:41 2001
@@ -1135,6 +1135,8 @@ extern char *bfd_elf_string_from_elf_sec
 extern char *bfd_elf_get_str_section
   PARAMS ((bfd *, unsigned));
 
+extern boolean _bfd_elf_copy_private_bfd_data
+  PARAMS ((bfd *, bfd *));
 extern boolean _bfd_elf_print_private_bfd_data
   PARAMS ((bfd *, PTR));
 extern void bfd_elf_print_symbol
--- bfd/elf.c.header	Sat Dec 15 16:08:37 2001
+++ bfd/elf.c	Sat Dec 15 16:07:02 2001
@@ -782,6 +782,24 @@ _bfd_elf_merge_sections (abfd, info)
 /* Print out the program headers.  */
 
 boolean
+_bfd_elf_copy_private_bfd_data (ibfd, obfd)
+     bfd *ibfd;
+     bfd *obfd;
+{
+  if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
+      || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
+    return true;
+
+  BFD_ASSERT (!elf_flags_init (obfd)
+	      || (elf_elfheader (obfd)->e_flags
+		  == elf_elfheader (ibfd)->e_flags));
+
+  elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags;
+  elf_flags_init (obfd) = true;
+  return true;
+}
+
+boolean
 _bfd_elf_print_private_bfd_data (abfd, farg)
      bfd *abfd;
      PTR farg;
--- bfd/elfxx-target.h.header	Thu Nov 15 10:18:25 2001
+++ bfd/elfxx-target.h	Sat Dec 15 16:10:11 2001
@@ -142,7 +142,7 @@ Foundation, Inc., 59 Temple Place - Suit
 #endif
 #ifndef bfd_elfNN_bfd_copy_private_bfd_data
 #define bfd_elfNN_bfd_copy_private_bfd_data \
-  ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true)
+  _bfd_elf_copy_private_bfd_data
 #endif
 #ifndef bfd_elfNN_bfd_print_private_bfd_data
 #define bfd_elfNN_bfd_print_private_bfd_data \

----- End forwarded message -----

-- 
: Michal ``,/\/\,       '' Moskal    | |            : GCS {C,UL}++++$
:          |    |alekith      @    |)|(| . org . pl : {E--, W, w-,M}-
:    Linux: We are dot in .ORG.    |                : {b,e>+}++ !tv h
: CurProj: ftp://ftp.pld.org.pl/people/malekith/ksi : PLD Team member



More information about the pld-devel-en mailing list