bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ld prints "mangled" error message


From: Gyorgy Matyasfalvi
Subject: ld prints "mangled" error message
Date: Mon, 28 Mar 2022 18:46:03 -0400

Hello,

It looks to me that undefined references to functions taking const pointers
are reported with a mangled function signature.

Example:
Take the following example, where `main.cpp` contains:

```
    void pc(const char * s);

    int main() {
        const char *msg = "Hello World!";
        pc(msg);
        return 0;
    }
```

If you compile it into an object file with

```
    g++ -c main.cpp
```

and then run

```
    ld main.o
```

you get

```
    ld: warning: cannot find entry symbol _start; defaulting to
0000000000401000
    ld: main.o: in function `main':
    main.cpp:(.text+0x1f): undefined reference to `pc(char const*)'
```

I think `pc(char const*)' should be `pc(const char*)'.


Details:
1. My ld version is:
- GNU ld (GNU Binutils for Ubuntu) 2.34

2. No patches applied to the ld source

3. Output of uname -a:
- Linux 5.16.11-76051611-generic
#202202230823~1646248261~20.04~2b22243-Ubuntu SMP PREEMPT Thu Ma x86_64
x86_64 x86_64 GNU/Linux

4. I tried compiling with the following compilers and got the same result:
- g++-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
- g++-8 (Ubuntu 8.4.0-3ubuntu2) 8.4.0
- g++-9 (Ubuntu 9.4.0-1ubuntu1~20.04) 9.4.0

4. No command arguments given to the linker
5. Attached
6. As mentioned above in the undefined reference error message I expect
`pc(const char*)' as opposed to `pc(char const*)'.


Let me know if you need anything else.
Thanks! Best wishes,
Gyorgy

Attachment: main.cpp
Description: Text Data

Attachment: main.o
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]