// File: /workspace/github_c_makefile_star2_O2/deplinenoise[P]vlink/ldscript.c
// Function: startofsecdef
static int startofsecdef(lword *s_addr,char *s_type,lword *s_lma)
/* Parse syntax of section definition until '{' and return VMA address,
   LMA address and type, when given.
   Returns bitfield. 0 when syntax is incorrect, 1 for correct,
   3 for s_addr set, 5 for s_lma set and 7 for both.
   Syntax: [addr-expr] [(type)] : [AT(lma)] { */
{
  int ret = 1;
  lword caddr = -2; /* this prevents expression evaluation during pre-parse */
  char *buf,c;

  if (current_ls)
    caddr = current_ls->relocmem->current;

  *s_type = 0;

  c = getchr();
  if (c != ':') {
    if (c != '(') {
      back(1);
      parse_expr(caddr,s_addr);
#if 0 /* @@@ not needed? address must be within memory region */
      if (current_ls) {
        if (current_ls->relocmem != defmem) {
          /* warning: address overrides specified VMA memory region */
          error(76,scriptname,getlineno(),'V');
          current_ls->relocmem = defmem;
        }
      }
#endif
      ret |= 2;
      c = getchr();
    }
    if (c == '(') {
      if (buf = getword()) {
        strcpy(s_type,buf);
        if (getchr() != ')') {
          error(66,scriptname,getlineno(),')');  /* ')' expected */
          back(1);
          ret = 0;
        }
        c = getchr();
      }
    }
  }

  if (c != ':') {
    error(66,scriptname,getlineno(),':');  /* ':' expected */
    back(1);
    return 0;
  }

  if (buf = getword()) {
    if (!strcmp(buf,"AT")) {
      if (getchr()=='(') {
        parse_expr(caddr,s_lma);
#if 0 /* @@@ not needed? address must be within memory region */
        if (current_ls) {
          if (current_ls->destmem != defmem) {
            if (current_ls->destmem != current_ls->relocmem) {
              /* warning: address overrides specified LMA memory region */
              error(76,scriptname,getlineno(),'L');
            }
            current_ls->destmem = atdefmem;
          }
        }
#endif
        if (ret)
          ret |= 4;
        if (getchr() != ')') {
          error(66,scriptname,getlineno(),')');  /* ')' expected */
          back(1);
          ret = 0;
        }
      }
      else {
        error(66,scriptname,getlineno(),'(');  /* '(' expected */
        back(1);
        ret = 0;
      }
    }
    else
      error(65,scriptname,getlineno(),buf);  /* unknown keyword ignored */
  }

  if (!startofblock('{'))
    ret = 0;

  return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %r13
movq 0x258cc(%rip), %rax     # 0x339f8
testq %rax, %rax
je 0xe13b
movq 0x30(%rax), %rax
movq 0x20(%rax), %r15
jmp 0xe13f
pushq $-0x2
popq %r15
movb $0x0, (%r12)
callq 0xf457
pushq $0x1
popq %rbx
cmpb $0x28, %al
je 0xe177
movzbl %al, %eax
cmpl $0x3a, %eax
je 0xe1ca
pushq $0x1
popq %rdi
callq 0xf4ac
movq %r15, %rdi
movq %r13, %rsi
callq 0xf5a5
callq 0xf457
pushq $0x3
popq %rbx
cmpb $0x28, %al
jne 0xe1c6
callq 0xe109
testq %rax, %rax
je 0xe219
movq %r12, %rdi
movq %rax, %rsi
callq 0x5080
callq 0xf457
cmpb $0x29, %al
je 0xe1c1
movq 0x25870(%rip), %r12     # 0x33a10
callq 0xf90a
xorl %ebx, %ebx
pushq $0x42
popq %rdi
pushq $0x29
popq %rcx
movq %r12, %rsi
movl %eax, %edx
xorl %eax, %eax
callq 0x6c19
pushq $0x1
popq %rdi
callq 0xf4ac
callq 0xf457
cmpb $0x3a, %al
jne 0xe219
callq 0xe109
testq %rax, %rax
je 0xe20a
movq %rax, %r12
cmpb $0x41, (%rax)
jne 0xe1ec
cmpb $0x54, 0x1(%r12)
jne 0xe1ec
cmpb $0x0, 0x2(%r12)
je 0xe252
movq 0x2581d(%rip), %r14     # 0x33a10
callq 0xf90a
pushq $0x41
popq %rdi
movq %r14, %rsi
movl %eax, %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0x6c19
pushq $0x7b
popq %rdi
callq 0xef1d
testl %eax, %eax
cmovel %eax, %ebx
jmp 0xe241
movq 0x257f0(%rip), %r14     # 0x33a10
callq 0xf90a
xorl %ebx, %ebx
pushq $0x42
popq %rdi
pushq $0x3a
popq %rcx
movq %r14, %rsi
movl %eax, %edx
xorl %eax, %eax
callq 0x6c19
pushq $0x1
popq %rdi
callq 0xf4ac
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0xf457
cmpb $0x28, %al
jne 0xe28e
movq %r15, %rdi
movq %r14, %rsi
callq 0xf5a5
leal 0x4(%rbx), %ebp
testl %ebx, %ebx
cmovel %ebx, %ebp
callq 0xf457
movl %ebp, %ebx
cmpb $0x29, %al
je 0xe20a
movq 0x25790(%rip), %r14     # 0x33a10
callq 0xf90a
xorl %ebx, %ebx
pushq $0x42
popq %rdi
pushq $0x29
jmp 0xe2a1
movq 0x2577b(%rip), %r14     # 0x33a10
callq 0xf90a
xorl %ebx, %ebx
pushq $0x42
popq %rdi
pushq $0x28
popq %rcx
movq %r14, %rsi
movl %eax, %edx
xorl %eax, %eax
callq 0x6c19
pushq $0x1
popq %rdi
callq 0xf4ac
jmp 0xe20a