public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/114849] New: Static function pointer
@ 2024-04-25  8:10 Manjunath.Bhavimani at elektrobit dot com
  2024-04-25  8:16 ` [Bug middle-end/114849] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Manjunath.Bhavimani at elektrobit dot com @ 2024-04-25  8:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114849

            Bug ID: 114849
           Summary: Static function pointer
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Manjunath.Bhavimani at elektrobit dot com
  Target Milestone: ---

Created attachment 58036
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58036&action=edit
Zip folder contains snippet and preprocessed *.c files

Hi,

I am using compiler v10.2 (v10.2_build_b1728_g5963bc8).

I observed some suspicious behavior in code compilation.

In my code, I have a static function with the same name in three different
files (Task1.c, Task2.c, and Task3.c). The static function is accessed through
a static volatile function pointer in respective files. The volatile qualifier
is added to avoid optimization. Each file has its own dedicated data section in
memory.

With gcc v10.2, I observed that the data section for all static variables of
Task2 file is initialized properly, but not for the other files (Task1 and
Task3).

As a result, our code crashes when the static function is accessed through the
static function pointer.

Reason: The static function pointer has an invalid address or is "0".

Our observation: When we moved to a higher version of gcc (i.e., v10.3), this
issue is not observed.

Kindly let us know if this issue is already known. If yes, could you please let
us know the right patch version for v10.2? Otherwise, this needs to be fixed in
v10.2.

Upgrading to the v10.3 toolchain is not within our project scope.

I have attached all files and snippets for your reference.

Note: I am working on SRAM; no flash is used, hence no data copy operation.

With Regards,

Manjunath Bhavimani

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/114849] Static function pointer
  2024-04-25  8:10 [Bug c/114849] New: Static function pointer Manjunath.Bhavimani at elektrobit dot com
@ 2024-04-25  8:16 ` pinskia at gcc dot gnu.org
  2024-04-25  8:19 ` Manjunath.Bhavimani at elektrobit dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-25  8:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114849

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |middle-end
             Target|                            |arm-eabi

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I wonder if this is a bug in the linker rather than gcc .

Are you using the same ld between gcc 10.3 and 10.2?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/114849] Static function pointer
  2024-04-25  8:10 [Bug c/114849] New: Static function pointer Manjunath.Bhavimani at elektrobit dot com
  2024-04-25  8:16 ` [Bug middle-end/114849] " pinskia at gcc dot gnu.org
@ 2024-04-25  8:19 ` Manjunath.Bhavimani at elektrobit dot com
  2024-04-25  8:23 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Manjunath.Bhavimani at elektrobit dot com @ 2024-04-25  8:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114849

--- Comment #2 from Manjunath Bhavimani <Manjunath.Bhavimani at elektrobit dot com> ---
Yes i am using same ld script, only compiler version changed

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/114849] Static function pointer
  2024-04-25  8:10 [Bug c/114849] New: Static function pointer Manjunath.Bhavimani at elektrobit dot com
  2024-04-25  8:16 ` [Bug middle-end/114849] " pinskia at gcc dot gnu.org
  2024-04-25  8:19 ` Manjunath.Bhavimani at elektrobit dot com
@ 2024-04-25  8:23 ` pinskia at gcc dot gnu.org
  2024-04-25  9:57 ` Manjunath.Bhavimani at elektrobit dot com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-25  8:23 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114849

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2024-04-25

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Can you provide the configure options you used for the 2 compilers?

And the exact command that is used to build your test program?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/114849] Static function pointer
  2024-04-25  8:10 [Bug c/114849] New: Static function pointer Manjunath.Bhavimani at elektrobit dot com
                   ` (2 preceding siblings ...)
  2024-04-25  8:23 ` pinskia at gcc dot gnu.org
@ 2024-04-25  9:57 ` Manjunath.Bhavimani at elektrobit dot com
  2024-04-29 11:55 ` Manjunath.Bhavimani at elektrobit dot com
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Manjunath.Bhavimani at elektrobit dot com @ 2024-04-25  9:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114849

--- Comment #4 from Manjunath Bhavimani <Manjunath.Bhavimani at elektrobit dot com> ---
We used same options for both toolchain version. Except linker option
-specs=nano.specs, this is not used for v10.3


Compiler Option:

-mcpu=cortex-m7 
-mthumb
-mlittle-endian
-mfpu=fpv5-sp-d16
-mfloat-abi=hard
-std=c99
-Os
-ggdb3
-Wall
-Wextra
-pedantic
-Wstrict-prototypes
-Wundef
-Wunused
-Werror=implicit-function-declaration
-Wsign-compare
-Wdouble-promotion
-fno-short-enums
-funsigned-char
-funsigned-bitfields
-fomit-frame-pointer
-fno-common
-fstack-usage
-fdump-ipa-all
-c
--sysroot=$(NEWLIB_DIR)
-specs=nano.specs
-specs=nosys.specs

Assembler Option:

-xassembler-with-cpp
-mcpu=cortex-m7
-mfpu=fpv5-sp-d16
-mfloat-abi=hard
-mthumb
-c

Linker Option:

--entry=$(ENTRYSYMBOL)
-nostartfiles
-mcpu=cortex-m7
-mthumb
-mfpu=fpv5-sp-d16
-mfloat-abi=hard
-mlittle-endian
-ggdb3
-lc
-lm
-lgcc
-specs=nano.specs
-specs=nosys.specs
--sysroot=$(LIB_DIR)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/114849] Static function pointer
  2024-04-25  8:10 [Bug c/114849] New: Static function pointer Manjunath.Bhavimani at elektrobit dot com
                   ` (3 preceding siblings ...)
  2024-04-25  9:57 ` Manjunath.Bhavimani at elektrobit dot com
@ 2024-04-29 11:55 ` Manjunath.Bhavimani at elektrobit dot com
  2024-04-29 12:26 ` Manjunath.Bhavimani at elektrobit dot com
  2024-05-09  6:52 ` Manjunath.Bhavimani at elektrobit dot com
  6 siblings, 0 replies; 8+ messages in thread
From: Manjunath.Bhavimani at elektrobit dot com @ 2024-04-29 11:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114849

--- Comment #5 from Manjunath Bhavimani <Manjunath.Bhavimani at elektrobit dot com> ---
Created attachment 58070
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58070&action=edit
Command to build .asm .o .elf

Please find attached make file for build command

Reading specs from /usr/lib/gcc/i686-pc-cygwin/3.4.4/specs
Configured with: /managed/gcc-build/final-v3-bootstrap/gcc-3.4.4-999/configure
--verbose --program-suffix=-3 --prefix=/usr --exec-prefix=/usr
--sysconfdir=/etc --libdir=/usr/lib --libexecdir=/usr/lib
--mandir=/usr/share/man --infodir=/usr/share/info
--enable-languages=c,ada,c++,d,f77,pascal,java,objc --enable-nls
--without-included-gettext --enable-version-specific-runtime-libs --without-x
--enabl
e-libgcj --disable-java-awt --with-system-zlib --enable-interpreter
--disable-libgcj-debug --enable-threads=posix --enable-java-gc=boehm
--disable-win32-registry --enable-sjlj-exceptions --enable-hash
-synchronization --enable-libstdcxx-debug
Thread model: posix
gcc version 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/114849] Static function pointer
  2024-04-25  8:10 [Bug c/114849] New: Static function pointer Manjunath.Bhavimani at elektrobit dot com
                   ` (4 preceding siblings ...)
  2024-04-29 11:55 ` Manjunath.Bhavimani at elektrobit dot com
@ 2024-04-29 12:26 ` Manjunath.Bhavimani at elektrobit dot com
  2024-05-09  6:52 ` Manjunath.Bhavimani at elektrobit dot com
  6 siblings, 0 replies; 8+ messages in thread
From: Manjunath.Bhavimani at elektrobit dot com @ 2024-04-29 12:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114849

--- Comment #6 from Manjunath Bhavimani <Manjunath.Bhavimani at elektrobit dot com> ---
Created attachment 58072
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58072&action=edit
compiler version comparison

Please find attached file where you can find the details for compiler versions
and related details when used to build with v10.2 and v10.3.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/114849] Static function pointer
  2024-04-25  8:10 [Bug c/114849] New: Static function pointer Manjunath.Bhavimani at elektrobit dot com
                   ` (5 preceding siblings ...)
  2024-04-29 12:26 ` Manjunath.Bhavimani at elektrobit dot com
@ 2024-05-09  6:52 ` Manjunath.Bhavimani at elektrobit dot com
  6 siblings, 0 replies; 8+ messages in thread
From: Manjunath.Bhavimani at elektrobit dot com @ 2024-05-09  6:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114849

--- Comment #7 from Manjunath Bhavimani <Manjunath.Bhavimani at elektrobit dot com> ---
Hi,
Should we get in touch with linker vendor for this?
BR,
Manjunath Bhavimani

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-05-09  6:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-25  8:10 [Bug c/114849] New: Static function pointer Manjunath.Bhavimani at elektrobit dot com
2024-04-25  8:16 ` [Bug middle-end/114849] " pinskia at gcc dot gnu.org
2024-04-25  8:19 ` Manjunath.Bhavimani at elektrobit dot com
2024-04-25  8:23 ` pinskia at gcc dot gnu.org
2024-04-25  9:57 ` Manjunath.Bhavimani at elektrobit dot com
2024-04-29 11:55 ` Manjunath.Bhavimani at elektrobit dot com
2024-04-29 12:26 ` Manjunath.Bhavimani at elektrobit dot com
2024-05-09  6:52 ` Manjunath.Bhavimani at elektrobit dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).