// File: /workspace/github_c_makefile_star2_O2/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
andq $0x0, 0x25a22(%rip)     # 0x339f8
movq %rdi, %rbx
movl $0x1, 0x25a29(%rip)     # 0x33a0c
pushq $0x2
popq %rbp
pushq $0x1
popq %r14
movq %rsp, %r15
callq 0xe109
testq %rax, %rax
je 0xe023
movq %rax, %r13
movq %rbx, %rdi
movq %rax, %rsi
movl %ebp, %edx
callq 0xd0f3
testl %eax, %eax
jne 0xdfed
callq 0xf457
cmpb $0x3d, %al
jne 0xe02e
movq %rbx, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0xd9e1
jmp 0xdfed
callq 0xf457
cmpb $0x3b, %al
je 0xdfed
jmp 0xe08c
movl %r14d, %edi
callq 0xf4ac
movq %rbx, %rdi
movq %r13, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xb7e9
testq %rax, %rax
je 0xe076
movq %rax, %r12
movq %rax, 0x2599e(%rip)     # 0x339f8
leaq 0x8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq %r15, %rdx
callq 0xe111
testl %eax, %eax
je 0xdfed
jmp 0xe0ac
leaq 0x12b1d(%rip), %rdi     # 0x20b9a
movq %r13, %rsi
xorl %eax, %eax
callq 0x6b2c
jmp 0xdfed
pushq $0x1
popq %rdi
callq 0xf4ac
xorl %r12d, %r12d
movq %r12, %rax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %r13d
testb $0x2, %r13b
je 0xe0c4
movq 0x30(%r12), %rdi
movq 0x8(%rsp), %rsi
callq 0xe2bb
cmpl $0x4, %r13d
jb 0xe0ff
movq 0x28(%r12), %rdi
cmpq 0x30(%r12), %rdi
jne 0xe0f6
leaq 0x12ab9(%rip), %rdi     # 0x20b96
movabsq $0x7fffffffffffffff, %rdx # imm = 0x7FFFFFFFFFFFFFFF
xorl %esi, %esi
callq 0xe2fc
movq %rax, %rdi
movq %rax, 0x28(%r12)
movq (%rsp), %rsi
callq 0xe2bb
andq $0x0, 0x258f9(%rip)     # 0x33a00
jmp 0xe097