Tech-stock investors had reason to cheer Wednesday after a second consecutive day of gains for the sector, lending credence to the notion that tech may be the market's new safe haven.

Shares of Google ( GOOG) finished up 3.2% to $317.91 after the Internet company announced it would finally put its formidable data-gathering power to use in targeted ads, joining such firms as Yahoo! ( YHOO) in the practice of aiming ads at people based on what Web pages they view. Yahoo! shares also ended on a positive note, up 1.2% to $13.39.

Motorola ( MOT), buoyed by a positive analyst note, finished the day up 3% to $3.49. Research In Motion ( RIMM), also in at least one analyst's good graces, closed up 3.5% to $40.34. Palm ( PALM) rose 6.4% to $7.36. iPhone maker Apple ( AAPL), which got a lift after introducing a new iPod shuffle, rose 4.6% to $92.68. Nokia ( NOK) shrugged off a report from Gartner that it had lost market share in the fourth quarter, rising 5.3% to $10.22.

Telecom services stocks didn't fare so well, with Comcast ( CMSCA) -- up 1.3% to $12.37 -- and AT&T ( T) -- up 1.4% to $23.35 -- the exceptions. Sprint ( S) fell 0.3% to $3.53. Deutsche Telekom ( DT) dropped 0.5% to $11.82. And Verizon ( VZ) finished the day down 0.6% to $27.44

In the semiconductor space, National Semiconductor ( NSM) shares fell 2.7% to $11.38 after reporting it would slash more than a quarter of its workforce. Texas Instruments ( TXN) rose 0.3% to $15.71. SanDisk rose 5% to $9.58. STMicroelectronics ( STM) rose 3.6% to $4.28. Intel ( INTC) eked out a 0.3% gain, ending up 4 cents from the previous day's close at $13.96. Qualcomm ( QCOM) fell 0.03% to $35,35.

Computer maker Dell ( DELL) rose 2.5% to $8.98. Hewlett-Packard ( HPQ) rose 5.8% to $28.61. IBM ( IBM) climbed 1.6% to $88.62.

More from Stocks

Tyson Foods CEO: We Aren't Done Making Deals

Tyson Foods CEO: We Aren't Done Making Deals

The Single Biggest Reason Trade War Fears Could Finally Topple the Stock Market

The Single Biggest Reason Trade War Fears Could Finally Topple the Stock Market

Stocks Dive Globally as U.S.-China Trade War Intensifies

Stocks Dive Globally as U.S.-China Trade War Intensifies

5 Stock Picks Under $10 for Millennials

5 Stock Picks Under $10 for Millennials

China Trade War, Google, JD.com, Tesla, Brooks Koepka - 5 Things You Must Know

China Trade War, Google, JD.com, Tesla, Brooks Koepka - 5 Things You Must Know