Add -N support to ELF?
H.J. Lu
hjl@nynexst.com
Mon Feb 20 13:20:00 GMT 1995
>
> From: hjl@nynexst.com (H.J. Lu)
> Date: Mon, 20 Feb 95 13:30:57 EST
>
> 1. When -N is not used, if the sh_flags of the current section
> is not compatible with the p_flags of the current segment, start
> a new segment.
>
> 2. When -N is used, behave just like the old way.
>
> This seems reasonable in principle. The trick is defining
> ``compatible'' is a useful fashion. I have not been able to think of
> a good definition, but I haven't thought about it all that much,
> either.
>
> I can make the changes. But I don't think may changes will be
> acceptable to everyone :-(. Will a new field in bfd_link_info help?
>
> A new field is not necessary. Check the flags field of the output
> field, and switch on the D_PAGED flag. D_PAGED is set by default, and
> turned off when -N (or -n) is used. For example, the a.out backend
> uses D_PAGED to determine whether the output file should be zmagic or
> omagic.
>
> Ian
>
This patch is derived from some patch I got, Eric? It should work
fine. Ian, is that ok to uncomment my patch to elf.sc with this one
applied? I guess the docs should be updated to reflect the usage
of -N in ELF.
Thanks.
--
H.J. Lu
NYNEX Science and Technology, Inc. hjl@nynexst.com
-----
*** elfcode.h Sat Feb 18 10:25:01 1995
--- elfcode.h.new Mon Feb 20 16:13:22 1995
***************
*** 1968,1974 ****
--- 1968,1986 ----
if (phdr->p_type != PT_NULL
&& (hdr->sh_offset - (phdr->p_offset + phdr->p_memsz)
== hdr->sh_addr - (phdr->p_vaddr + phdr->p_memsz))
+ #if 1
+ && (last_type != SHT_NOBITS || hdr->sh_type == SHT_NOBITS)
+ /* We check to see if the binary is for demand page. We
+ want to make sure the curent section is compatible with
+ the current segment. Otherwise, start a new segment. We
+ have to be very careful about elf.sc. Don't put any
+ writable sections into the text segment. */
+ && (((abfd->flags & D_PAGED) == 0)
+ || (((hdr->sh_flags & SHF_WRITE) == 0 && (phdr->p_flags & PF_W) == 0)
+ || ((hdr->sh_flags & SHF_WRITE) != 0 && (phdr->p_flags & PF_W) != 0))))
+ #else
&& (last_type != SHT_NOBITS || hdr->sh_type == SHT_NOBITS))
+ #endif
{
bfd_size_type adjust;
More information about the Gas2
mailing list