Lines Matching refs:segment
1004 sections, but that doesn't work if the segment
1007 the segment LMA. It is assumed that the
1008 segment will contain sections with contiguous
1015 be placed at the end of one segment or the
2450 of the form segment<NUM>, where NUM is generally the index in the
2452 generate the names segment<NUM>a and segment<NUM>b.
2462 for the single program segment. The first has the length specified by
2463 the file size of the segment, and the second has the length specified
2464 by the difference between the two sizes. In effect, the segment is split
2604 /* Check for any processor-specific program segment types. */
3665 PT_INTERP segment. In this case, assume we also need a
3666 PT_PHDR segment, although that may not be true for all
3673 /* We need a PT_DYNAMIC segment. */
3679 /* We need a PT_GNU_RELRO segment. */
3685 /* We need a PT_GNU_EH_FRAME segment. */
3691 /* We need a PT_GNU_STACK segment. */
3700 /* We need a PT_NOTE segment. */
3702 /* Try to create just one PT_NOTE segment
3704 gABI requires that within a PT_NOTE segment
3722 /* We need a PT_TLS segment. */
3743 /* Find the segment that contains the output_section of section. */
3765 /* Create a mapping from a set of sections to a program segment. */
3792 /* Include the headers in the first PT_LOAD segment. */
3800 /* Create the PT_DYNAMIC segment, which includes DYNSEC. Returns NULL
3820 /* Possibly add or remove segments from the segment map. */
3832 sections from the segment map. We also remove excluded
3833 sections. Finally, any PT_LOAD segment without sections is
3938 /* If we have a .interp section, then create a PT_PHDR segment for
3939 the program headers and a PT_INTERP segment for the .interp
3972 segment when the start of the second section can be placed within
4011 segment. */
4015 /* If we don't have a segment yet, then we don't need a new
4023 segment. */
4030 the previous section, then we need a new segment. */
4037 section can be included in the current segment. */
4043 /* If putting this section in this segment would force us to
4044 skip a page in the segment, then we need a new segment. */
4051 nonloadable section in the same segment.
4059 file, then there is no other reason for a new segment. */
4068 segment, unless they are on the same page in memory
4078 /* Otherwise, we can use the same segment. */
4105 /* We need a new program segment. We must create a new program
4130 /* Create a final PT_LOAD program segment, but not if it's just
4145 /* If there is a .dynamic section, throw in a PT_DYNAMIC segment. */
4156 add a PT_NOTE segment. We don't use bfd_get_section_by_name,
4208 /* If there are any SHF_TLS output sections, add PT_TLS segment. */
4254 segment. */
4314 /* Make a PT_GNU_RELRO segment only when it isn't empty. */
4360 place the section into a segment. */
4590 /* An ELF segment (described by Elf_Internal_Phdr) may contain a
4618 segment alignment later in this function, so we are relying
4619 on at least one PT_LOAD segment appearing before a PT_TLS
4620 segment. */
4665 /* Find out whether this segment contains any loadable
4679 /* We shouldn't need to align the segment on disk since
4680 the segment doesn't need file space, but the gABI
4684 p_offset for just this segment. (OFF_ADJUST is
4692 PT_DYNAMIC segment. */
4698 (_("%B: The first section in the PT_DYNAMIC segment is not the .dynamic section"),
4881 a note section in a PT_NOTE segment. These take
4916 /* Check that all sections are in a PT_LOAD segment.
4929 /* Looks like we have overlays packed into the segment. */
4945 (_("%B: section `%A' can't be allocated in segment %d"),
4994 (_("%B: warning: allocated section `%s' not in segment"),
5054 /* There is a segment that contains both the file headers and the
5070 /* The segment contains sections, so use the first one. */
5073 /* Use the first (i.e. lowest-addressed) section in any segment. */
5107 /* During linking the range of the RELRO segment is passed
5284 /* Set e_type in ELF header to ET_EXEC for -pie -Ttext-segment=. */
5290 Elf_Internal_Phdr *segment = elf_tdata (abfd)->phdr;
5291 Elf_Internal_Phdr *end_segment = &segment[num_segments];
5295 for (; segment < end_segment; segment++)
5296 if (segment->p_type == PT_LOAD && p_vaddr > segment->p_vaddr)
5297 p_vaddr = segment->p_vaddr;
5603 Elf_Internal_Phdr *segment;
5623 /* Returns the end address of the segment + 1. */
5624 #define SEGMENT_END(segment, start) \
5625 (start + (segment->p_memsz > segment->p_filesz \
5626 ? segment->p_memsz : segment->p_filesz))
5628 #define SECTION_SIZE(section, segment) \
5630 != SEC_THREAD_LOCAL || segment->p_type == PT_TLS) \
5634 the given segment. VMA addresses are compared. */
5635 #define IS_CONTAINED_BY_VMA(section, segment) \
5636 (section->vma >= segment->p_vaddr \
5637 && (section->vma + SECTION_SIZE (section, segment) \
5638 <= (SEGMENT_END (segment, segment->p_vaddr))))
5641 the given segment. LMA addresses are compared. */
5642 #define IS_CONTAINED_BY_LMA(section, segment, base) \
5644 && (section->lma + SECTION_SIZE (section, segment) \
5645 <= SEGMENT_END (segment, base)))
5647 /* Handle PT_NOTE segment. */
5677 /* Decide if the given section should be included in the given segment.
5679 1. It is within the address space of the segment -- we use the LMA
5680 if that is set for the segment and the VMA otherwise,
5682 segment.
5684 4. The section has not already been allocated to a previous segment.
5686 6. PT_TLS segment includes only SHF_TLS sections.
5690 #define IS_SECTION_IN_INPUT_SEGMENT(section, segment, bed) \
5691 ((((segment->p_paddr \
5692 ? IS_CONTAINED_BY_LMA (section, segment, segment->p_paddr) \
5693 : IS_CONTAINED_BY_VMA (section, segment)) \
5695 || IS_NOTE (segment, section)) \
5696 && segment->p_type != PT_GNU_STACK \
5697 && (segment->p_type != PT_TLS \
5699 && (segment->p_type == PT_LOAD \
5700 || segment->p_type == PT_TLS \
5702 && (segment->p_type != PT_DYNAMIC \
5703 || SECTION_SIZE (section, segment) > 0 \
5704 || (segment->p_paddr \
5705 ? segment->p_paddr != section->lma \
5706 : segment->p_vaddr != section->vma) \
5711 /* If the output section of a section in the input segment is NULL,
5712 it is removed from the corresponding output segment. */
5713 #define INCLUDE_SECTION_IN_SEGMENT(section, segment, bed) \
5714 (IS_SECTION_IN_INPUT_SEGMENT (section, segment, bed) \
5733 /* Initialise the segment mark field. */
5742 for (i = 0, segment = elf_tdata (ibfd)->phdr;
5744 i++, segment++)
5745 if (segment->p_paddr != 0)
5755 for (i = 0, segment = elf_tdata (ibfd)->phdr;
5757 i++, segment++)
5762 if (segment->p_type == PT_INTERP)
5764 if (IS_SOLARIS_PT_INTERP (segment, section))
5766 /* Mininal change so that the normal section to segment
5768 segment->p_vaddr = section->vma;
5772 if (segment->p_type != PT_LOAD)
5774 /* Remove PT_GNU_RELRO segment. */
5775 if (segment->p_type == PT_GNU_RELRO)
5776 segment->p_type = PT_NULL;
5780 /* Determine if this segment overlaps any previous segments. */
5786 || !SEGMENT_OVERLAPS (segment, segment2))
5790 if (segment2->p_vaddr < segment->p_vaddr)
5792 /* Extend SEGMENT2 to include SEGMENT and then delete
5793 SEGMENT. */
5794 extra_length = (SEGMENT_END (segment, segment->p_vaddr)
5803 segment->p_type = PT_NULL;
5807 segment = elf_tdata (ibfd)->phdr;
5812 /* Extend SEGMENT to include SEGMENT2 and then delete
5815 - SEGMENT_END (segment, segment->p_vaddr));
5819 segment->p_memsz += extra_length;
5820 segment->p_filesz += extra_length;
5829 for (i = 0, segment = elf_tdata (ibfd)->phdr;
5831 i++, segment++)
5845 if (segment->p_type == PT_NULL)
5849 /* Compute how many sections might be placed into this segment. */
5854 /* Find the first section in the input segment, which may be
5855 removed from the corresponding output segment. */
5856 if (IS_SECTION_IN_INPUT_SEGMENT (section, segment, bed))
5865 /* Allocate a segment map big enough to contain
5873 /* Initialise the fields of the segment map. Default to
5874 using the physical address of the segment in the input BFD. */
5876 map->p_type = segment->p_type;
5877 map->p_flags = segment->p_flags;
5880 /* If the first section in the input segment is removed, there is
5881 no need to preserve segment physical address in the corresponding
5882 output segment. */
5885 map->p_paddr = segment->p_paddr;
5889 /* Determine if this segment contains the ELF file header
5891 map->includes_filehdr = (segment->p_offset == 0
5892 && segment->p_filesz >= iehdr->e_ehsize);
5895 if (!phdr_included || segment->p_type != PT_LOAD)
5898 (segment->p_offset <= (bfd_vma) iehdr->e_phoff
5899 && (segment->p_offset + segment->p_filesz
5903 if (segment->p_type == PT_LOAD && map->includes_phdrs)
5909 /* Special segments, such as the PT_PHDR segment, may contain
5913 if (segment->p_type == PT_LOAD)
5914 (*_bfd_error_handler) (_("%B: warning: Empty loadable segment"
5926 to add their corresponding output sections to the segment map.
5931 In this case we can continue to use the segment LMA from the
5935 In this case we can change the segment's LMA to match the LMA
5940 placed in the current segment which will have to have its size,
5941 and possibly its LMA changed, and a new segment or segments will
5945 In this case we can change the segment's LMA to match the LMA
5946 of the first section and we will have to create a new segment
5951 to a segment, they are removed from this array. */
5957 /* Step One: Scan for segment vs section LMA conflicts.
5959 Also add the sections to the current segment. In the common
5961 we have completely filled the segment, and there is nothing
5977 if (INCLUDE_SECTION_IN_SEGMENT (section, segment, bed))
5988 && segment->p_vaddr != 0
5992 && output_section->vma == (segment->p_vaddr
6000 map->p_paddr = segment->p_vaddr;
6002 /* Match up the physical address of the segment with the
6004 if (IS_CONTAINED_BY_LMA (output_section, segment, map->p_paddr)
6005 || IS_COREFILE_NOTE (segment, section)
6007 && IS_CONTAINED_BY_VMA (output_section, segment)))
6015 /* We assume that if the section fits within the segment
6017 segment. */
6033 /* Step Two: Adjust the physical address of the current segment,
6037 /* All of the sections fitted within the segment as currently
6038 specified. This is the default case. Add the segment to
6051 segment. So, we must account for that in the output
6052 segment's vma. */
6062 /* At least one section fits inside the current segment.
6069 /* None of the sections fitted inside the current segment.
6070 Change the current segment
6075 /* Offset the segment physical address from the lma
6096 here of the number we used and the segment we chose
6108 those that fit to the current segment and removing them from the
6110 possible sections have been assigned to the current segment it is
6112 to be assigned, a new segment is constructed before repeating
6121 /* Fill the current segment with sections that fit. */
6133 if (IS_CONTAINED_BY_LMA (output_section, segment, map->p_paddr)
6134 || IS_COREFILE_NOTE (segment, section))
6138 /* If the first section in a segment does not start at
6139 the beginning of the segment, then something is
6157 maxpagesize then we need to start a new segment. */
6188 /* Add the current segment to the list of built segments. */
6195 segments. Create a new segment here, initialise it
6206 /* Initialise the fields of the segment map. Set the physical
6210 map->p_type = segment->p_type;
6211 map->p_flags = segment->p_flags;
6264 Elf_Internal_Phdr *segment;
6275 /* If all the segment p_paddr fields are zero, don't set
6279 for (i = 0, segment = elf_tdata (ibfd)->phdr;
6281 i++, segment++)
6282 if (segment->p_paddr != 0)
6288 for (i = 0, segment = elf_tdata (ibfd)->phdr;
6290 i++, segment++)
6299 /* Compute how many sections are in this segment. */
6305 if (ELF_SECTION_IN_SEGMENT (this_hdr, segment))
6313 /* Allocate a segment map big enough to contain
6322 /* Initialize the fields of the output segment map with the
6323 input segment. */
6325 map->p_type = segment->p_type;
6326 map->p_flags = segment->p_flags;
6328 map->p_paddr = segment->p_paddr;
6330 map->p_align = segment->p_align;
6337 /* The PT_GNU_RELRO segment may contain the first a few
6339 section isn't in the PT_GNU_RELRO segment. We won't
6340 change the size of the PT_GNU_RELRO segment.
6343 map->p_size = segment->p_memsz;
6347 /* Determine if this segment contains the ELF file header
6349 map->includes_filehdr = (segment->p_offset == 0
6350 && segment->p_filesz >= iehdr->e_ehsize);
6353 if (! phdr_included || segment->p_type != PT_LOAD)
6356 (segment->p_offset <= (bfd_vma) iehdr->e_phoff
6357 && (segment->p_offset + segment->p_filesz
6361 if (segment->p_type == PT_LOAD && map->includes_phdrs)
6375 if (ELF_SECTION_IN_SEGMENT (this_hdr, segment))
6392 seg_off = this_hdr->sh_offset - segment->p_offset;
6394 seg_off = this_hdr->sh_addr - segment->p_vaddr;
6395 if (section->lma - segment->p_paddr != seg_off)
6406 map->header_size = lowest_section->vma - segment->p_vaddr;
6413 - segment->p_paddr);
6441 Elf_Internal_Phdr *segment;
6449 /* Regenerate the segment map if p_paddr is set to 0. */
6453 /* Initialize the segment mark field. */
6459 for (i = 0, segment = elf_tdata (ibfd)->phdr;
6461 i++, segment++)
6465 which severly confuses things, so always regenerate the segment
6467 if (segment->p_paddr == 0
6468 && segment->p_memsz == 0
6469 && (segment->p_type == PT_INTERP || segment->p_type == PT_DYNAMIC))
6481 /* Check if this section is covered by the segment. */
6483 if (ELF_SECTION_IN_SEGMENT (this_hdr, segment))
6518 Elf_Internal_Phdr *segment;
6523 for (i = 0, segment = elf_tdata (ibfd)->phdr;
6525 i++, segment++)
6526 if (segment->p_type == PT_LOAD
6527 && maxpagesize < segment->p_align)
6528 maxpagesize = segment->p_align;