https://bugs.llvm.org/show_bug.cgi?id=48192

            Bug ID: 48192
           Summary: Issue with Bad Hidden Symbol Linkage
                    (__start/stop___objc_constant_string) in Objective-C
                    2.0 with Gnustep
           Product: clang
           Version: 10.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected]

Created attachment 24167
  --> https://bugs.llvm.org/attachment.cgi?id=24167&action=edit
LLD Log for compiling the first program

Ubuntu 20.04

clang version 10.0.0-4ubuntu1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

Compile Command:
clang -x objective-c $(gnustep-config --objc-libs & gnustep-config
--objc-flags) -lgnustep-base -fuse-ld=lld test.m

Description:
When compiling a simple test case of Objective-C with Clang, I ran into the
following errors.

ld.lld: error: undefined hidden symbol: __start___objc_constant_string
>>> referenced by test.m
>>>               /tmp/test-564724.o:(.objc_init)

ld.lld: error: undefined hidden symbol: __stop___objc_constant_string
>>> referenced by test.m
>>>               /tmp/test-564724.o:(.objc_init)

These issues persit for lld, ld, and gold linkers.

The sample program to reproduce the bug is bellow.

```objc
#import<Foundation/Foundation.h>

int main() {
   BOOL condition = NO;
   while(condition) {
      NSLog(@"123456789");
   }
}
```

There also appears to be some interaction with the internals of
NSConstantString (@-strings) and Clang optimization. I theorize this because
the following cases compile and run correctly. The first case suggests
something due to NSConstantString. On 64-bit systems, a pointer can hold 8
bytes which is 1-8. The second case has more than 8 bytes but Clang appears to
handle it differently. This could be due to the first example optimizing out
the loop but keeping residual constant string data or the second case
optimizing to an infinite loop.

```objc
#import<Foundation/Foundation.h>

int main() {
  BOOL condition = NO;
  while(condition) {
    NSLog(@"12345678");
  }
}
```

```objc
#import<Foundation/Foundation.h>

int main() {
  BOOL condition = YES;
  while(condition) {
    NSLog(@"123456789");
  }
}
```

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to