From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by sourceware.org (Postfix) with ESMTPS id DF4B23858C50 for ; Fri, 20 Jan 2023 09:25:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DF4B23858C50 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-x102f.google.com with SMTP id x2-20020a17090a46c200b002295ca9855aso8500220pjg.2 for ; Fri, 20 Jan 2023 01:25:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=OwVz+hoavQPYtjdNhpsCOWB0/vRA+iJjZeTV9/PmS6o=; b=eyHQ3HQ6En9VpwToVXsfivEWE2s1awnNl4uOV/5vVe5omwQ/QYE6NAWffG5Pvo3oAF iJC4W9QdLY1KWsvUN0GPMz44R5fWVPkQcVz51GiPfT1tpVLCqJLJ170R/QL+mYUcRp4B iLcYkf0q+6sFWBZ/jAEBl46nOITRy0eTFhhfywActT6wV6wfago7Fm2lp7W8dwmow/ay RIWL1SV3MrGt40m6wu0NjGbxOXnCl1deXLO2R+giZDmcejrE5MdBCbPQDt2f0lDByIvx TUn1zXOeKa12ormkzwUUq4cIcoBznGfYhZ0aWQ5jWtGUzeFvuu8KKn2nSMs911Q/WbHT LICQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=OwVz+hoavQPYtjdNhpsCOWB0/vRA+iJjZeTV9/PmS6o=; b=ly2FHTt1yTu/WDIOl1QPpLNfFYTtTWRKqBwc1PA/fH7ijKBsx/MYwqBvG4mp2j0htG 3tZpX+3jioR9KwG8oW+T04RxYXXtFWMdhN78fwh0ZswZT8r9oNb6lFEoktFwGhw71KwD Va+ZJrHaNtwNp0tBneeWDh0Dk2fjAJaLePu8QSYqwm4qh8LVTkZMjpYq2zlW9s5k2t6B 0D5dyNeHO3qTfZMfzKgRINHlm4sZkBg0hPaQs8bzT0jr6wOeIrpn0O9DzOctvWA1+CLd fL605qWcSYnKh5Edbi5ObxMfBobnVrHHYhWxd+0Wofo+TPBes6J0RdGWcLpDq9oPszEz eAJA== X-Gm-Message-State: AFqh2kotypI0+ivyiNW3mRXT1Nf6zWS+xxs0Bvq19Y1TNjPj0td9UcIO o6wCjyR5LDtWIOQGh3HFFBzHftpplHTKV9AkievN+Irlwnk= X-Google-Smtp-Source: AMrXdXsREy+lPvsJS28+gLZ0ZUNch4Y08kzpmAnOGIlqkO7J9tL0uTHjdvE1fnDWlxmpSXuiXtlXg7WvraAKCA7S/wc= X-Received: by 2002:a17:90a:65cb:b0:227:4d5:6d64 with SMTP id i11-20020a17090a65cb00b0022704d56d64mr1620642pjs.29.1674206701840; Fri, 20 Jan 2023 01:25:01 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: ratheesh kannoth Date: Fri, 20 Jan 2023 14:54:50 +0530 Message-ID: Subject: Re: .data segment To: gcc-help@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: i mean -> when i analyze 2.s, uninitialized static variable, "sta_char_unini" is in .text section. But i expected it to be in .data section. On Fri, Jan 20, 2023 at 2:50 PM ratheesh kannoth wrote: > > Hi List, > > When I compiled (gcc -O0 -g --no-pic -S -fverbose-asm -c 2.c -o > 2.s) below program to assembly code, it showed an uninitialized > static variable, "sta_char_unini" section. > But when we execute the program, I can see that "sta_char_unini" is > in .data section (thru /proc//maps). What is wrong in my analysis > of 2.s ? > > =================== 2.c ================================== > #include > #include > #include > > static char sta_char_unini; > static char sta_char_ini = 'B'; > > char char_unini; > char char_ini = '6'; > > int main() > { > > sta_char_unini = 5; > > char str1[] = "Hello world"; > char *str2 = "How are you"; > printf("Pid = %u\n", getpid()); > > printf("sta_char_unini=%p sta_char_ini=%p\n", &sta_char_unini, > &sta_char_ini); > > while (1); > > return 0; > } > > =================================== 2.s =================== > > .file "2.c" > .text > .Ltext0: > .local sta_char_unini > .comm sta_char_unini,1,1 > .data > .type sta_char_ini, @object > .size sta_char_ini, 1 > sta_char_ini: > .byte 66 > .comm char_unini,1,1 > .globl char_ini > .type char_ini, @object > .size char_ini, 1 > char_ini: > .byte 54 > .section .rodata > .LC0: > .string "How are you" > .LC1: > .string "Pid = %u\n" > .align 8 > .LC2: > .string "sta_char_unini=%p sta_char_ini=%p\n" > .text > .globl main > .type main, @function > main: > .LFB0: > .file 1 "2.c" > .loc 1 12 1 > .cfi_startproc > ...................................... > ........................................