[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug ld/30254] iostream crashes with ld linker for windows targets
From: |
euloanty at live dot com |
Subject: |
[Bug ld/30254] iostream crashes with ld linker for windows targets |
Date: |
Sun, 21 May 2023 08:36:59 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=30254
--- Comment #14 from cqwrteur <euloanty at live dot com> ---
Some one tries this program:
#include <Windows.h>
#include <cstdio>
#include <cstdlib>
#include <iostream>
typedef void* (__cdecl* fn_type_t)(void* self, char const* string);
int main()
{
MessageBoxA(nullptr,"pause",nullptr,0);
auto hModule = GetModuleHandleA("libstdc++-6.dll");
auto cout = reinterpret_cast<void*>(GetProcAddress(hModule,
"_ZSt4cout"));
auto fn = reinterpret_cast<fn_type_t>(GetProcAddress(hModule,
"_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc"));
fn(cout, "Hello World!\n");
std::cout << "Hello World!\n";
return 0;
}
He found std::cout binds to the wrong address for ld.
Here is a variable inside the PE file.
void * address = &std::cout;
Now, we want to make this = address, but GNU LD gives you this = &address.
This pointer is incorrect,
so it will definitely result in an error.
--
You are receiving this mail because:
You are on the CC list for the bug.
- [Bug ld/30254] iostream crashes with ld linker for windows targets, (continued)
- [Bug ld/30254] iostream crashes with ld linker for windows targets, euloanty at live dot com, 2023/05/21
- [Bug ld/30254] iostream crashes with ld linker for windows targets, euloanty at live dot com, 2023/05/21
- [Bug ld/30254] iostream crashes with ld linker for windows targets, euloanty at live dot com, 2023/05/21
- [Bug ld/30254] iostream crashes with ld linker for windows targets, euloanty at live dot com, 2023/05/21
- [Bug ld/30254] iostream crashes with ld linker for windows targets, euloanty at live dot com, 2023/05/21
- [Bug ld/30254] iostream crashes with ld linker for windows targets, euloanty at live dot com, 2023/05/21
- [Bug ld/30254] iostream crashes with ld linker for windows targets, euloanty at live dot com, 2023/05/21
- [Bug ld/30254] iostream crashes with ld linker for windows targets, euloanty at live dot com, 2023/05/21
- [Bug ld/30254] iostream crashes with ld linker for windows targets, euloanty at live dot com, 2023/05/21
- [Bug ld/30254] iostream crashes with ld linker for windows targets, euloanty at live dot com, 2023/05/21
- [Bug ld/30254] iostream crashes with ld linker for windows targets,
euloanty at live dot com <=
- [Bug ld/30254] iostream crashes with ld linker for windows targets, euloanty at live dot com, 2023/05/21
- [Bug ld/30254] iostream crashes with ld linker for windows targets, euloanty at live dot com, 2023/05/21
- [Bug ld/30254] iostream crashes with ld linker for windows targets, euloanty at live dot com, 2023/05/21
- [Bug ld/30254] iostream crashes with ld linker for windows targets, euloanty at live dot com, 2023/05/21