Skip to content

Commit 5696ab0

Browse files
elfcpp/:
* elfcpp.h (PN_XNUM): Define. gold/: * output.cc (Output_section_headers::do_sized_write): Write large segment count to sh_info field. (Output_file_header::do_sized_write): For large segment count, write PN_XNUM to e_phnum field.
1 parent 2046a35 commit 5696ab0

4 files changed

Lines changed: 28 additions & 3 deletions

File tree

‎elfcpp/ChangeLog‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2010-01-19 Ian Lance Taylor <iant@google.com>
2+
3+
* elfcpp.h (PN_XNUM): Define.
4+
15
2009-12-14 Ian Lance Taylor <iant@google.com>
26

37
* elfcpp_file.h: Revert last patch.

‎elfcpp/elfcpp.h‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,15 @@ enum EM
302302
// Old MN10200 objects used 0xdead (EM_MN10200 is correct).
303303
};
304304

305+
// A special value found in the Ehdr e_phnum field.
306+
307+
enum
308+
{
309+
// Number of program segments stored in sh_info field of first
310+
// section headre.
311+
PN_XNUM = 0xffff
312+
};
313+
305314
// Special section indices.
306315

307316
enum

‎gold/ChangeLog‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2010-01-19 Ian Lance Taylor <iant@google.com>
2+
3+
* output.cc (Output_section_headers::do_sized_write): Write large
4+
segment count to sh_info field.
5+
(Output_file_header::do_sized_write): For large segment count,
6+
write PN_XNUM to e_phnum field.
7+
18
2010-01-15 Viktor Kutuzov <vkutuzov@accesssoftek.com>
29

310
* arm.cc (Arm_relocate_functions::thm_jump6): New function.

‎gold/output.cc‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,9 @@ Output_section_headers::do_sized_write(Output_file* of)
213213
else
214214
oshdr.put_sh_link(shstrndx);
215215

216-
oshdr.put_sh_info(0);
216+
size_t segment_count = this->segment_list_->size();
217+
oshdr.put_sh_info(segment_count >= elfcpp::PN_XNUM ? segment_count : 0);
218+
217219
oshdr.put_sh_addralign(0);
218220
oshdr.put_sh_entsize(0);
219221
}
@@ -470,8 +472,11 @@ Output_file_header::do_sized_write(Output_file* of)
470472
else
471473
{
472474
oehdr.put_e_phentsize(elfcpp::Elf_sizes<size>::phdr_size);
473-
oehdr.put_e_phnum(this->segment_header_->data_size()
474-
/ elfcpp::Elf_sizes<size>::phdr_size);
475+
size_t phnum = (this->segment_header_->data_size()
476+
/ elfcpp::Elf_sizes<size>::phdr_size);
477+
if (phnum > elfcpp::PN_XNUM)
478+
phnum = elfcpp::PN_XNUM;
479+
oehdr.put_e_phnum(phnum);
475480
}
476481

477482
oehdr.put_e_shentsize(elfcpp::Elf_sizes<size>::shdr_size);

0 commit comments

Comments
 (0)