// File: /workspace/github_c_makefile_star2_O0/deplinenoise[P]vlink/ldscript.c
// Function: define_phdrs
static void define_phdrs(struct GlobalVars *gv)
/* Syntax: */
/* <phdrname> <type> [FILEHDR] [PHDRS] [AT(addr)] [FLAGS(flags)]; */
{
  char phdrname[MAXLEN];
  char *str;
  struct Phdr *p;
  int need_phdr;

  if (!startofblock('{'))
    return;

  while (str = getword()) {
    char c;
    uint32_t type;
    uint16_t flags = 0;
    lword addr = ADDR_NONE;

    strcpy(phdrname,str);
    if (str = getword()) {

      if (!strncmp(str,"PT_",3)) {
        switch (str[3]) {
          case 'L': type = PT_LOAD; break;
          case 'D': type = PT_DYNAMIC; break;
          case 'I': type = PT_INTERP; break;
          case 'N': type = PT_NOTE; break;
          case 'S': type = PT_SHLIB; break;
          case 'P': type = PT_PHDR; break;
          default:
            error(99,scriptname,getlineno(),str);   /* Illegal PHDR type */
            type = PT_NULL;
            break;
        }

        while (str = getword()) {
          if (!strcmp(str,"FILEHDR")) {
            flags |= PHDR_FILEHDR;
          }
          else if (!strcmp(str,"PHDRS")) {
            flags |= PHDR_PHDRS;
          }
          else if (!strcmp(str,"AT")) {
            addr = term_absexp();
            flags |= PHDR_ADDR;
          }
          else if (!strcmp(str,"FLAGS")) {
            flags |= PHDR_FLAGS | ((uint32_t)term_absexp() & 7);
          }
          else
            error(65,scriptname,getlineno(),str);  /* unknown keyword ignored */
        }
        c = getchr();
        if (c != ';') {
          error(66,scriptname,getlineno(),';');  /* ',' expected */
          if (c == '}')
            return;
        }

        add_phdr(gv,phdrname,type,flags,addr,NULL,NULL);
      }
      else {
        error(99,scriptname,getlineno(),str);   /* Illegal PHDR type */
        skipblock(1,0,';');
      }
    }
    else {
      error(78,scriptname,getlineno());   /* missing argument */
      skipblock(1,0,';');
    }
  }
  endofblock('{','}');

  /* add a default PHDR when no PT_PHDR was defined, but was requested
     to be part of a PT_LOAD PHDR */
  for (p=gv->phdrlist,need_phdr=0; p; p=p->next) {
    if (p->type == PT_PHDR)
      return;
    if (p->flags & PHDR_PHDRS)
      need_phdr = 1;
  }
  if (need_phdr)
    add_phdr(gv,defhdr,PT_PHDR,PHDR_PHDRS,ADDR_NONE,defmem,defmem);
}

// Assembly:
subq $0x168, %rsp            # imm = 0x168
movq %rdi, 0x160(%rsp)
movl $0x7b, %edi
callq 0x17e00
cmpl $0x0, %eax
jne 0x172b3
jmp 0x17654
jmp 0x172b5
callq 0x167b0
movq %rax, 0x58(%rsp)
cmpq $0x0, %rax
je 0x175aa
movw $0x0, 0x42(%rsp)
movq $-0x1, 0x38(%rsp)
leaq 0x60(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x5060
callq 0x167b0
movq %rax, 0x58(%rsp)
cmpq $0x0, %rax
je 0x17570
movq 0x58(%rsp), %rdi
leaq 0x1ea22(%rip), %rsi     # 0x35d2a
movl $0x3, %edx
callq 0x5050
cmpl $0x0, %eax
jne 0x17534
movq 0x58(%rsp), %rax
movsbl 0x3(%rax), %eax
addl $-0x44, %eax
movl %eax, %ecx
movq %rcx, 0x30(%rsp)
subl $0xf, %eax
ja 0x17384
movq 0x30(%rsp), %rax
leaq 0x1e74d(%rip), %rcx     # 0x35a8c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x1, 0x44(%rsp)
jmp 0x173b5
movl $0x2, 0x44(%rsp)
jmp 0x173b5
movl $0x3, 0x44(%rsp)
jmp 0x173b5
movl $0x4, 0x44(%rsp)
jmp 0x173b5
movl $0x5, 0x44(%rsp)
jmp 0x173b5
movl $0x6, 0x44(%rsp)
jmp 0x173b5
movq 0x2d665(%rip), %rax     # 0x449f0
movq %rax, 0x28(%rsp)
callq 0x18f50
movq 0x28(%rsp), %rsi
movl %eax, %edx
movq 0x58(%rsp), %rcx
movl $0x63, %edi
movb $0x0, %al
callq 0x8c00
movl $0x0, 0x44(%rsp)
jmp 0x173b7
callq 0x167b0
movq %rax, 0x58(%rsp)
cmpq $0x0, %rax
je 0x174b5
movq 0x58(%rsp), %rdi
leaq 0x1e957(%rip), %rsi     # 0x35d2e
callq 0x5130
cmpl $0x0, %eax
jne 0x173f5
movzwl 0x42(%rsp), %eax
orl $0x800, %eax            # imm = 0x800
movw %ax, 0x42(%rsp)
jmp 0x174b0
movq 0x58(%rsp), %rdi
leaq 0x1e7e4(%rip), %rsi     # 0x35be5
callq 0x5130
cmpl $0x0, %eax
jne 0x1741f
movzwl 0x42(%rsp), %eax
orl $0x400, %eax            # imm = 0x400
movw %ax, 0x42(%rsp)
jmp 0x174ae
movq 0x58(%rsp), %rdi
leaq 0x1e284(%rip), %rsi     # 0x356af
callq 0x5130
cmpl $0x0, %eax
jne 0x17450
callq 0x17f90
movq %rax, 0x38(%rsp)
movzwl 0x42(%rsp), %eax
orl $0x80, %eax
movw %ax, 0x42(%rsp)
jmp 0x174ac
movq 0x58(%rsp), %rdi
leaq 0x1e8da(%rip), %rsi     # 0x35d36
callq 0x5130
cmpl $0x0, %eax
jne 0x17481
callq 0x17f90
movl %eax, %ecx
andl $0x7, %ecx
orl $0x40, %ecx
movzwl 0x42(%rsp), %eax
orl %ecx, %eax
movw %ax, 0x42(%rsp)
jmp 0x174aa
movq 0x2d568(%rip), %rax     # 0x449f0
movq %rax, 0x20(%rsp)
callq 0x18f50
movq 0x20(%rsp), %rsi
movl %eax, %edx
movq 0x58(%rsp), %rcx
movl $0x41, %edi
movb $0x0, %al
callq 0x8c00
jmp 0x174ac
jmp 0x174ae
jmp 0x174b0
jmp 0x173b7
callq 0x18790
movb %al, 0x4b(%rsp)
movsbl 0x4b(%rsp), %eax
cmpl $0x3b, %eax
je 0x17502
movq 0x2d521(%rip), %rax     # 0x449f0
movq %rax, 0x18(%rsp)
callq 0x18f50
movq 0x18(%rsp), %rsi
movl %eax, %edx
movl $0x42, %edi
movl $0x3b, %ecx
movb $0x0, %al
callq 0x8c00
movsbl 0x4b(%rsp), %eax
cmpl $0x7d, %eax
jne 0x17500
jmp 0x17654
jmp 0x17502
movq 0x160(%rsp), %rdi
leaq 0x60(%rsp), %rsi
movl 0x44(%rsp), %edx
movw 0x42(%rsp), %ax
movq 0x38(%rsp), %r8
xorl %ecx, %ecx
movl %ecx, %r9d
movzwl %ax, %ecx
movq $0x0, (%rsp)
callq 0x17660
jmp 0x1756e
movq 0x2d4b5(%rip), %rax     # 0x449f0
movq %rax, 0x10(%rsp)
callq 0x18f50
movq 0x10(%rsp), %rsi
movl %eax, %edx
movq 0x58(%rsp), %rcx
movl $0x63, %edi
movb $0x0, %al
callq 0x8c00
movl $0x1, %edi
xorl %esi, %esi
movl $0x3b, %edx
callq 0x187c0
jmp 0x175a5
movq 0x2d479(%rip), %rax     # 0x449f0
movq %rax, 0x8(%rsp)
callq 0x18f50
movq 0x8(%rsp), %rsi
movl %eax, %edx
movl $0x4e, %edi
movb $0x0, %al
callq 0x8c00
movl $0x1, %edi
xorl %esi, %esi
movl $0x3b, %edx
callq 0x187c0
jmp 0x172b5
movl $0x7b, %edi
movl $0x7d, %esi
callq 0x17f10
movq 0x160(%rsp), %rax
movq 0x1f8(%rax), %rax
movq %rax, 0x50(%rsp)
movl $0x0, 0x4c(%rsp)
cmpq $0x0, 0x50(%rsp)
je 0x17616
movq 0x50(%rsp), %rax
cmpl $0x6, 0x20(%rax)
jne 0x175ea
jmp 0x17654
movq 0x50(%rsp), %rax
movzwl 0x24(%rax), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
je 0x17605
movl $0x1, 0x4c(%rsp)
jmp 0x17607
movq 0x50(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x50(%rsp)
jmp 0x175d5
cmpl $0x0, 0x4c(%rsp)
je 0x17654
movq 0x160(%rsp), %rdi
movq 0x2887c(%rip), %rsi     # 0x3fea8
movq 0x2d3cd(%rip), %r9      # 0x44a00
movq 0x2d3c6(%rip), %rax     # 0x44a00
movl $0x6, %edx
movl $0x400, %ecx            # imm = 0x400
movq $-0x1, %r8
movq %rax, (%rsp)
callq 0x17660
addq $0x168, %rsp            # imm = 0x168
retq
nopl (%rax)