Hmm.. This fixes problem with chpax. Should I install it to our cvs or we're downgrading? [slightly modifed for our version] ----- Forwarded message from "H . J . Lu" ----- Date: Sat, 15 Dec 2001 16:20:17 -0800 From: "H . J . Lu" To: Michal Moskal Cc: binutils@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 * 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 Wed May 23 20:36:02 2001 +++ bfd/elf-bfd.h Sat Dec 29 17:50:17 2001 @@ -979,6 +979,7 @@ PARAMS ((bfd *, unsigned, unsigned)); 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 PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type)); --- 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 -----