// File: /workspace/github_c_makefile_star2_O3/deplinenoise[P]vlink/ldscript.c
// Function: next_secdef
struct LinkedSection *next_secdef(struct GlobalVars *gv)
/* Find next section definition in script and return the machting
   structure. */
{
  char *keyword;
  struct Phdr *p;

  level = 1;
  current_ls = NULL;

  do {
    while (keyword = getword()) {
      if (check_command(gv,keyword,SCMDF_GLOBAL)) {
        continue;
      }
      else if (getchr() == '=') {
        symbol_assignment(gv,keyword,0);
      }

      else {
        /* check for section definition */
        char s_type[MAXLEN];
        struct LinkedSection *ls;
        int ret;
        lword s_addr,s_lma;

        back(1);
        if (ls = find_lnksec(gv,keyword,0,0,0,0)) {
          current_ls = ls;
          if (ret = startofsecdef(&s_addr,s_type,&s_lma)) {
            if (ret & 2)
              change_address(ls->relocmem,s_addr);
            if (ret & 4) {
              if (ls->destmem == ls->relocmem)
                ls->destmem = add_memblock("lma",MEM_DEFORG,MEM_DEFLEN);
              change_address(ls->destmem,s_lma);
            }

            secdefbase = NULL;
            return ls;
          }
        }
        else
          ierror("next_secdef(): No Section for %s defined",keyword);
      }
    }
  }
  while (getchr() == ';');
  back(1);

#if 0 /* @@@ don't do it - it modifies header size !!! */
  /* scan for empty segments and declare them as unused */
  for (p=gv->phdrlist; p; p=p->next) {
    if (p->type!=PT_PHDR && (p->start==ADDR_NONE || p->start_vma==ADDR_NONE)) {
      p->start = p->start_vma = p->file_end = p->mem_end = 0;
      p->flags &= ~PHDR_USED;
    }
  }
#endif
  return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdi, %rbx
movl $0x1, 0x24de8(%rip)     # 0x3361c
movq $0x0, 0x24dc9(%rip) # 0x33608
leaq 0x8(%rsp), %r15
leaq 0x10(%rsp), %r12
movq %rsp, %r13
movl $0x1, %edi
callq 0xff64
testq %rax, %rax
je 0xe8f7
movq %rax, %r14
movq %rbx, %rdi
movq %r14, %rsi
movl $0x2, %edx
callq 0xd8ec
testl %eax, %eax
jne 0xe8e1
callq 0xfeed
cmpb $0x3d, %al
jne 0xe88e
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0xe258
jmp 0xe8e1
movl $0x1, %edi
callq 0xff51
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xbe13
testq %rax, %rax
je 0xe8d0
movq %rax, %rbp
movq %rax, 0x24d4c(%rip)     # 0x33608
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0xe981
testl %eax, %eax
je 0xe8e1
jmp 0xe912
leaq 0x142b3(%rip), %rdi     # 0x22b8a
movq %r14, %rsi
xorl %eax, %eax
callq 0x52b0
movl $0x1, %edi
callq 0xff64
movq %rax, %r14
testq %rax, %rax
jne 0xe862
callq 0xfeed
cmpb $0x3b, %al
je 0xe84c
movl $0x1, %edi
callq 0xff51
xorl %ebp, %ebp
jmp 0xe96c
movl %eax, %r14d
testb $0x2, %r14b
je 0xe929
movq 0x30(%rbp), %rdi
movq 0x8(%rsp), %rsi
callq 0xeb62
cmpl $0x4, %r14d
jb 0xe961
movq 0x28(%rbp), %rdi
cmpq 0x30(%rbp), %rdi
jne 0xe958
leaq 0x14246(%rip), %rdi     # 0x22b86
movabsq $0x7fffffffffffffff, %rdx # imm = 0x7FFFFFFFFFFFFFFF
xorl %esi, %esi
callq 0xeba5
movq %rax, %rdi
movq %rax, 0x28(%rbp)
movq (%rsp), %rsi
callq 0xeb62
movq $0x0, 0x24ca4(%rip) # 0x33610
movq %rbp, %rax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq