This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Preserve e_flags.


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@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 \


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]