Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F168186439
D7255.id18593.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D7255.id18593.diff
View Options
Index: sys/kern/imgact_elf.c
===================================================================
--- sys/kern/imgact_elf.c
+++ sys/kern/imgact_elf.c
@@ -1323,6 +1323,8 @@
* Collect info about the core file header area.
*/
hdrsize = sizeof(Elf_Ehdr) + sizeof(Elf_Phdr) * (1 + seginfo.count);
+ if (seginfo.count + 1 >= PN_XNUM)
+ hdrsize += sizeof(Elf_Shdr);
__elfN(prepare_notes)(td, ¬elst, ¬esz);
coresize = round_page(hdrsize + notesz) + seginfo.size;
@@ -1618,10 +1620,10 @@
{
Elf_Ehdr *ehdr;
Elf_Phdr *phdr;
+ Elf_Shdr *shdr;
struct phdr_closure phc;
ehdr = (Elf_Ehdr *)hdr;
- phdr = (Elf_Phdr *)((char *)hdr + sizeof(Elf_Ehdr));
ehdr->e_ident[EI_MAG0] = ELFMAG0;
ehdr->e_ident[EI_MAG1] = ELFMAG1;
@@ -1645,14 +1647,34 @@
ehdr->e_flags = 0;
ehdr->e_ehsize = sizeof(Elf_Ehdr);
ehdr->e_phentsize = sizeof(Elf_Phdr);
- ehdr->e_phnum = numsegs + 1;
ehdr->e_shentsize = sizeof(Elf_Shdr);
- ehdr->e_shnum = 0;
ehdr->e_shstrndx = SHN_UNDEF;
+ if (numsegs + 1 < PN_XNUM) {
+ ehdr->e_phnum = numsegs + 1;
+ ehdr->e_shnum = 0;
+ } else {
+ ehdr->e_phnum = PN_XNUM;
+ ehdr->e_shnum = 1;
+
+ ehdr->e_shoff = ehdr->e_phoff +
+ (numsegs + 1) * ehdr->e_phentsize;
+ KASSERT(ehdr->e_shoff == hdrsize - sizeof(Elf_Shdr),
+ ("e_shoff: %zu, hdrsize - shdr: %zu",
+ ehdr->e_shoff, hdrsize - sizeof(Elf_Shdr)));
+
+ shdr = (Elf_Shdr *)((char *)hdr + ehdr->e_shoff);
+ memset(shdr, 0, sizeof(*shdr));
+ /* See table 7-7 of Solaris "Linker and Libraries Guide" */
+ shdr->sh_type = SHT_NULL;
+ shdr->sh_size = ehdr->e_shnum;
+ shdr->sh_link = ehdr->e_shstrndx;
+ shdr->sh_info = numsegs + 1;
+ }
/*
* Fill in the program header entries.
*/
+ phdr = (Elf_Phdr *)((char *)hdr + ehdr->e_phoff);
/* The note segement. */
phdr->p_type = PT_NOTE;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Aug 27, 6:54 PM (15 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37410510
Default Alt Text
D7255.id18593.diff (1 KB)
Attached To
Mode
D7255: Extend ELF coredump to support more than 65535 segments
Attached
Detach File
Event Timeline
Log In to Comment