Last active
October 14, 2023 21:50
-
-
Save sapphire-arches/45fc6d3c57b569247173dc7fb3eb6e22 to your computer and use it in GitHub Desktop.
MCVE for ARM mode ODR violation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "a.hpp" | |
A::~A() { } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
class A { | |
public: | |
A(); | |
virtual ~A(); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
arm-none-eabi-gcc -x c++ -o main.o -c -Wall -flto -ffunction-sections -mthumb-interwork -mcpu=cortex-a9 -O2 -mfpu=neon -marm main.cpp | |
arm-none-eabi-gcc -x c++ -o a.o -c -Wall -flto -ffunction-sections -mthumb-interwork -mcpu=cortex-a9 -O2 -mfpu=neon -mthumb a.cpp | |
arm-none-eabi-gcc -o main --specs=nano.specs --specs=rdimon.specs -Wall -flto -ffunction-sections -mthumb-interwork -mcpu=cortex-a9 -O2 -mfpu=neon main.o a.o | |
a.hpp:5:7: warning: type 'struct A' violates the C++ One Definition Rule [-Wodr] | |
5 | class A { | |
| ^ | |
a.hpp:5:7: note: a type with different virtual table pointers is defined in another translation unit | |
5 | class A { | |
| ^ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "a.hpp" | |
int main(int argc, char const * const * argv) { | |
A a; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CFLAGS=-Wall -flto -ffunction-sections -mthumb-interwork -mcpu=cortex-a9 -O2 -mfpu=neon | |
main: main.o a.o | |
arm-none-eabi-gcc -o $@ --specs=nano.specs --specs=rdimon.specs $(CFLAGS) $^ | |
a.o: a.cpp | |
arm-none-eabi-gcc -x c++ -o $@ -c $(CFLAGS) -mthumb $< | |
main.o: main.cpp | |
arm-none-eabi-gcc -x c++ -o $@ -c $(CFLAGS) -marm $< | |
.PHONY: clean | |
clean: | |
rm -f *.o | |
rm -f main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment