<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Issue with Bad Hidden Symbol Linkage (__start/stop___objc_constant_string) in Objective-C 2.0 with Gnustep"
   href="https://bugs.llvm.org/show_bug.cgi?id=48192">48192</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Issue with Bad Hidden Symbol Linkage (__start/stop___objc_constant_string) in Objective-C 2.0 with Gnustep
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>10.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>austin.chase.m@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=24167" name="attach_24167" title="LLD Log for compiling the first program">attachment 24167</a> <a href="attachment.cgi?id=24167&action=edit" title="LLD Log for compiling the first program">[details]</a></span>
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
<span class="quote">>>> referenced by test.m
>>>               /tmp/test-564724.o:(.objc_init)</span >

ld.lld: error: undefined hidden symbol: __stop___objc_constant_string
<span class="quote">>>> referenced by test.m
>>>               /tmp/test-564724.o:(.objc_init)</span >

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");
  }
}
```</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>